newbie question: building and using a static lib
Mon Mar 6 14:41:00 GMT 2006
I would like to apologize in the beginning for my question... I assume
itÂ´s dead easy; but IÂ´m a newbie, and obviously IÂ´m missing something
OK, so hereÂ´s what IÂ´m trying to do:
My System is an x86 with Fedora Core 4 and gcc Version 4.0.2.
I have a bunch of GUI classes (using Qt4.1.1). I compile these classes
and put them into a static lib file (by running "ar rcs mylib.a *.o").
This works without any problems.
Then, I have a small demo application "main.cpp", where I want to use
these classes. I include the corresponding headers and compile main.cpp
into main.o without problems. Then, I try to link main.o into an
g++ -I./src/ -I/usr/local/Trolltech/Qt-4.1.1/include/QtGui
-L./ -lmyclass -lstdc++ -lQtGui_debug -lQtCore_debug -o main main_d.o
Here, the linke seems to find everything nicely (the Qt libs as well as
my own lib), but then starts to complain about undefined references to
all the stuff that is inside my lib. It will not, however, complain
about anything that is inside the Qt libs.
I have tried to move the libs around (specify my own lib first, then
last, etc.), to no avail. I have also tried "nm" on my lib - it lists a
lot of symbols, including the ones that gcc is complaining about.
Please tell me - what am I doing wrong here ?? Or might it be that I
canÂ´t mix my static lib with the dynamic Qt libs ? I donÂ´t think so..
(BTW: when I link everything into an executable, everything is fine...
so I know that basically my code is OK...)
Once again sorry to bother you with such a trivial matter, but IÂ´m
running out of ideas what I am doing wrong...
thanks very much in advance,
& best regards
More information about the Gcc-help