This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Question about how to compile multiple files with g++
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Yen <m9142610 at student dot nsysu dot edu dot tw>, gcc-help at gcc dot gnu dot org
- Date: Thu, 17 Mar 2005 06:12:25 -0600
- Subject: Re: Question about how to compile multiple files with g++
- References: <20050317085856.M425@student.nsysu.edu.tw>
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