This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: need to link 3 files...how?
- To: help-gcc at gnu dot org
- Subject: Re: need to link 3 files...how?
- From: Arthur Gold <agold at bga dot com>
- Date: Wed, 10 Nov 1999 12:48:31 -0600
- Newsgroups: gnu.gcc.help
- References: <80cdbv$5gj$1@faatcrl.faa.gov>
- Xref: wodc7nx0 gnu.gcc.help:1767
Bruce Fisher wrote:
>
> i have 3 files named:
> main.cpp
> person.cpp
> person.h
>
> i've #included person.h in my main.cpp.
> how do i compile this to run. i know i have to link them together but i dont
> know how to do that. someone told me i would have to use "make". i read the
> mn pages on this but it really didnt help me out with understanding make.
> can anyone help?
>
> thanks in advance
You're linking _two_ files, the result of compileing main.cpp and the
result of compiling person.cpp.
g++ -c main.cpp <==== this creates main.o
g++ -c person.cpp <==== this creates person.o
g++ -o <programname> main.o person.o <==== this uses g++ to link them
===========
put whatever you want the program name to be in place of
<programname> above.
HTH,
--ag
--
Artie Gold, Austin, TX
mailto:agold@bga.com or mailto:agold@cs.utexas.edu
--
"If you come to a fork in the road, take it." L. P. Berra