linking problems

M. Ritscher mr203010spam at gmx.net
Wed Apr 30 19:50:08 BST 2003


Hi all,

I'v got some problems linking a project. Whilst browsing the archive/web I 
learned a bit about libraries and how to handle them using KDevelop. Still 
there is something I can't get working in KDevelop.

Imaging the following project structure:

-----------------------------
projectCPP (folder
   folderA (static library)
     folderB (static libary)
       ClassB1
       ClassB2
     ClassA1
     ClassA2
  ClassProjectCPP
----------------------------

with the following references between the classes:

------------------------------------
ClassProjectCPP::ClassProjectCPP(){
  ClassB1* b1 = new ClassB1();
  b1->foo();
}

ClassB1::foo(){
  ClassA1* a1 = new ClassA1();
  a1->foobar();
}

ClassA1::foobar(){
  //do something
}
-----------------------------------

When linking I get an error:

/bin/sh ../libtool --silent --mode=link --tag=CXX g++ -Wnon-virtual-dtor 
-Wno-long-long -Wundef -Wall -pedantic -W -Wpointer-arith 
-Wmissing-prototypes -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE 
-Wcast-align -Wconversion -O2 -O0 -g3 -Wall -fno-exceptions -fno-check-new -o 
projectcpp -L/usr/X11R6/lib -L/usr/lib/qt3/lib -L/opt/kde3/lib -R 
/opt/kde3/lib -R /usr/lib/qt3/lib -R /usr/X11R6/lib projectcpp.o main.o 
projectcpp.moc.o ./folderA/libfolderA.a ./folderA/folderB/libfolderB.a 
-lqt-mt -lpng -lz -lm -lXext -lX11 -lSM -lICE -lpthread -lkdecore -lkdeui
./folderA/folderB/libfolderB.a(classb1.o): In function `ClassB1::foo()':
>>>>>>>>>>>>>>>>
/home/moppel/projects/projectcpp/projectcpp/folderA/folderB/classb1.cpp:27: 
undefined reference to `ClassA1::ClassA1[in-charge]()'
>>>>>>>>>>>>>>>>
/home/moppel/projects/projectcpp/projectcpp/folderA/folderB/classb1.cpp:29: 
undefined reference to `ClassA1::foobar()'
collect2: ld returned 1 exit status

From my understanding this is bound to fail because "libfolderA.a" isn't  
referenced until "libfolderB.a" is linked.

When swapping these to around and issuing the same command at the command line
(note the order)
... ./folderA/folderB/libfolderB.a  ./folderA/libfolderA.a ...

~/projects/projectcpp/projectcpp> ../libtool --silent --mode=link --tag=CXX 
g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -pedantic -W 
-Wpointer-arith -Wmissing-prototypes -Wwrite-strings -ansi 
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -O2 -O0 -g3 -Wall 
-fno-exceptions -fno-check-new -o projectcpp -L/usr/X11R6/lib 
-L/usr/lib/qt3/lib -L/opt/kde3/lib -R /opt/kde3/lib -R /usr/lib/qt3/lib -R 
/usr/X11R6/lib projectcpp.o main.o projectcpp.moc.o 
./folderA/folderB/libfolderB.a ./folderA/libfolderA.a -lqt-mt -lpng -lz -lm 
-lXext -lX11 -lSM -lICE -lpthread -lkdecore -lkdeui

it succeeds.

How can I get this working?

I've put the project on the web in case the above isn't expressed clearly 
enough.
"http://home.arcor.de/mritscher/kdevelop/projectCpp.tar.bz2"

Any help appreciated! Forgive me if it's not a kdevelop related issue.
I'm using KDevelop 2.1.5 on KDE 3.1.0

Cheers,

Moppel


-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list