I'm compiling programs via command-line with mingw32 gcc. As the source files increase, I'm running into some problems. Firstly, consider the following script:
gcc -Wall -I"MyDir" -I"MyDir2" -L"MyLibDir" -L"MyLibDir2" -l lib1 -l lib2 -l lib3 -c file.c
gcc -Wall -I"MyDir" -I"MyDir2" -L"MyLibDir" -L"MyLibDir2" -l lib1 -l lib2 -l lib3 -c file2.c
gcc -Wall -I"MyDir" -I"MyDir2" -L"MyLibDir" -L"MyLibDir2" -l lib1 -l lib2 -l lib3 -c file3.c
gcc -o myprog.exe file1.o file2.o file3.o
Now, can't I just tell gcc
the compiler directories -I
, linker directories -L
and link libraries -l
only once and then compile the second and third source file with the same options without having to retype them? Something like
gcc -define-options -Wall -I"MyDir" -I"MyDir2" -L"MyLibDir" -L"MyLibDir2" -l lib1 -l lib2 -l lib3
gcc -Wall -c file1.c
gcc -Wall -c file2.c
gcc -Wall -c file3.c
gcc -o myprog.exe file1.o file2.o file3.o