[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ / g++ question



On Mon, 06 Sep 1999, Adam Wendt wrote:
> 
> > AFAIK, #including .cpp files is not "standard practice". Or is it ? Am I
> > missing something ?
> >
> > CHeers,
> > --
> > Donovan
> 
> I'm just guessing (because i'm not an experienced programmer) but from
> compiling lots of programs I would guess that normally you would compile the
> .cpp files separatly and then link the .o files or whatever and that is
> wwhere your problem is.  And by not '#include'ing the .cpp files in main.cpp
> the compiler cant tell how to combine the files properly.
> 
> -Adam-
> 
Correct Adam, but by suppling the -o (output) option, g++ should call
ld and link the object files on the fly and produce the executible
file matrix.

This is assuming nothing special is being done here (ie: no extra
includes or libs) and that everything is in the same directory.
Something like this should work:

]$ g++ -o matrix *.cpp

same as: g++ -o matrix vector.cpp matrix.cpp main.cpp

Donovan, you did not say what the linker was complaining about. That
would be a clue.

--
R.G. Mayhue
rgmayhue@serenesoftware.com