CaptRage61
Programmer
Does anyone know how to create a make file? For example, I have 3 c programs: myprog1.c, myprog2.c and myprog3.c. How do I creat a make file that will compile all of these programs by 1 command and make them executable???
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
all: myprog1.o myprog2.o myprog3.o
cc -o all myprog1.o myprog2.o myprog3.o
myprog1.o: myprog1.c
cc -c myprog1.c
myprog2.o: myprog2.c
cc -c myprog2.c
myprog3.o: myprog3.c
cc -c myprog3.c
~
bash-2.05$ make all
cc -o all myprog1.o myprog2.o myprog3.o
myprog2.o: In function `main':
myprog2.o(.text+0x0): multiple definition of `main'
myprog1.o(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 219 to 107 in myprog2.o
myprog3.o: In function `main':
myprog3.o(.text+0x98): multiple definition of `main'
myprog1.o(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 107 to 178 in myprog3.o
collect2: ld returned 1 exit status
make: *** [all] Error 1
cc -o all myprog1.o myprog2.o myprog3.o
all: myprog1 myprog2 myprog3
myprog1: myprog1.o
cc -o myprog1 myprog1.o
myprog2: myprog2.o
cc -o myprog2 myprog2.o
myprog3: myprog3.o
cc -o myprog3 myprog3.o
all: myprog1 myprog2 myprog3