I wish to compile many .cc files into one .o file.
I'm using a bash script, which I need to do, to build my unit test source files into a unit_test.o file, but it's saying "g++: cannot specify -o with -c or -S with multiple files" I link these source files in the next stage of the script.
So far I have;
g++ -Wno-deprecated -std=c++0x \
-o $Unit_Test_Output_Directory/unit_test.o \
-c $Unit_Test_Source_Directory/test1.cc $Unit_Test_Source_Directory/test2.cc
Then after that I have my -I's and -L's, the "\" in bash is used to split commands onto multiple lines.
Then in the linking stage I link my unit_test.o and my source file's .o's into a unit_test_executable.
Can somebody help me out there? Do I need to keep calling the build function for -o unit_test1.o -c test1.cc, and then for test 2... and link unit_test1.o and unit_test2.o in the linking stage?
I've also unsuccessfully tried:
g++ -Wno-deprecated -std=c++0x \
-o $Unit_Test_Output_Directory/unit_test1.o \
$Unit_Test_Output_Directory/unit_test2.o \
-c $Unit_Test_Source_Directory/test1.cc \
$Unit_Test_Source_Directory/test2.cc