Mail Archives: djgpp/2000/02/11/23:09:23
Aha... I had just posted a similar problem, but got no answers. FINALLY
found a reference in, of all places, the FAQ. The order of your libraries
matters, it turns out. You should always do it in the order:
anyobjectfiles.o -lyourlib -lyournextlib -lstdcxx
That is, with stdcxx LAST, and any object files FIRST, and your own libary
file(s) sandwiched between.
It worked for me (after I'd pulled out most of my hair). The FAQ reference
is 8.10.
Let me know if this helps!
Nick.
----- Original Message -----
From: <Riddler02 AT aol DOT com>
Newsgroups: comp.os.msdos.djgpp
To: <djgpp AT delorie DOT com>
Sent: Thursday, February 10, 2000 12:42 AM
Subject: Linking to my library sucks! Help!
> I know that everybody and their mother has already complained at some
> point about not being about to link to a library, but I really couldn't
> resist - I have read every FAQ and mail archive I could find about the
topic,
> yet I can't find any specific answers on how to successfully link programs
to
> a library I have created.
> My library consists of header file, MAPS.H, which defines some
constants
> and some classes, and the other file is souce code, MAPS.CPP, which
includes
> MAPS.H and defines all of the member functions declared in MAPS.H. The
> library builds perfectly into LIBMAPS.A.
> However, problems begin when I try linking this library to my game.
The
> game includes MAPS.H, the library is checked off and spelled correctly
(minus
> the "lib" part, just "maps") since I'm using RHIDE, it's located in the
> correct directory, and the program compiles fine, but come the linking
stage
> I get several "undefined reference" errors of my class member functions
that
> are defined in the library.
> I've tried linking the program from the command line and it gives me
the
> same errors, so I dont think anything is wrong with RHIDE. I've tried
adding
> the library to my project (instead of checking it off in the Library menu)
> but that didnt do anything. I'm pretty sure there's nothing wrong with my
> code because if I put the same member function definitions and constants
> directly into my one program source file instead of trying to link to the
> library, the program builds and runs perfectly.
> I'm very stumped and I would hate to continue developing my game
having
> to re-compile EVERYTHING each time, so any help that anybody could give
would
> be greatly appreciated. Thanx!
>
> -Kevin
>
- Raw text -