This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about how to compile multiple files with g++


Hi Yen,

Try this...
g++ -Wall -O2 -s main.cpp a.cpp b.cpp

>So, how do I compile this program to generate the objective file? 

Ahh, the above does generate object files, it generates the executable.  To generate the object files of each of those, try this...
g++ -c -Wall -O2 main.cpp
g++ -c -Wall -O2 a.cpp
g++ -c -Wall -O2 b.cpp

And then to get the executable...
g++ -s main.o a.o b.o

HTH,
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]