Hello, Sen-Lung Chen wrote:
> g++: cannot specify -o with -c or -S and multiple compilations The compiler driver g++ has two basic modes of operation: Producing object files, and producing executables. There are more modes, but that is beyond what you need now. Producing object files is triggered by the -c option and requires a source file to be compiled as argument and optionally an output filename via -o. Producing an executable, i.e. linking, is triggered by not specifying an option changing the mode, i.e. not -c. You may specify source files, object files, libraries to be compiled and linked, and there must be a main function in one of these files, or linking fails. So in your case there should be g++ -c file.cc -o file.o for every source file, and g++ -o executablename object1.o object2.o main.o to produce the executable. There are abbreviations: 1. g++ -c file1.cc file2.cc file3.cc (note that there must not be a -o) is about the same as: g++ -c file1.cc -o file1.o g++ -c file2.cc -o file2.o g++ -c file2.cc -o file3.o 2. g++ -o executablename object1.cc object2.cc main.cc -lm (note that there must be a main function somewhere) is about the same as g++ -c object1.cc -o temporary1.o g++ -c object2.cc -o temporary2.o g++ -c main.cc -o temporary3.o g++ -o executablename temporary[123].o -lm rm temporary[123].o So your problem was, that you were mixing abbreviations and the basic invocations in ways that are not allowed. Hope this helps, Bernd Strieder _______________________________________________ Help-gplusplus mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gplusplus
