This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

newbie question: building and using a static lib


Hi everybody,

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
here...

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
executable using:

g++ -I./src/ -I/usr/local/Trolltech/Qt-4.1.1/include/QtGui
-I/usr/local/Trolltech/Qt-4.1.1/include/QtCore/
-I/usr/local/Trolltech/Qt-4.1.1/include/
-L/usr/local/Trolltech/Qt-4.1.1/lib/
-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
Dieter


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]