[PyKDE] SIP: Including a static C++ library

Jahn Otto Næsgaard Andersen jotto at jotto.no
Sun Jan 25 15:34:01 GMT 2004


Hi,

I have a static (.a) C++ library. I have written a SIP file for one of
those classes:

%Module HoloLib

class Bird
{
%TypeHeaderCode
#include "bird.h"
%End

  public:
    Bird(const char *);


};

I SIP this file and then compile and link the resulting cpp files with:

g++ -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -pipe -fPIC -O2 -Wall -W
-D_REENTRANT -c -I.. -I. -I/usr/local/include/python2.3
-I/home/jotto/work/hololib/src   sipHoloLibcmodule.cpp
g++ -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -pipe -fPIC -O2 -Wall -W
-D_REENTRANT -c -I.. -I. -I/usr/local/include/python2.3
-I/home/jotto/work/hololib/src   sipHoloLibBird.cpp
g++ -shared -Wl,-rpath,/usr/lib/qt-x11-free-3.2.3/lib
-L/usr/local/lib/python2.3/site-packages
-L/home/jotto/work/hololib/build -lHoloLib  -o hololib.so *.o 

The static library, libHoloLib.a, is located in
/home/jotto/work/hololib/build. The include files are located in
/home/jotto/work/hololib/src.

The resulting hololib.so library is compiled without errors. I then try
to copy it into /usr/local/lib/python2.3/site-packages and try to load
it in python, but I'm getting a

>>> from hololib import *
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: /usr/local/lib/python2.3/site-packages/hololib.so:
undefined symbol: _ZN4BirdC1EPKc

According to c++filt, the _ZN4BirdC1EPKc symbol is
Bird::Bird[in-charge](char const*)


It looks to me like the -lHoloLib linker option doesn't link in
everything I need in libHoloLib.a. The size of libhololib.so is also
very small compared to libHoloLib.so: 9685 bytes compared to 294570.

I have also tried to use the -E option when linking, with the same
result.


Any suggestions?


I am using SIP 4.0rc2 on Linux Redhat 8.0, Qt 3.2.0, gcc 3.2.


Thanks!

Jahn Otto






More information about the PyQt mailing list