Wrapping C++ class with SWIG, Mac OS X

Diez B. Roggisch deets at nospam.web.de
Sat Apr 12 09:44:55 EDT 2008


Paul Anton Letnes schrieb:
> Okay, installed SIP. Looks promising, following the tutorial on
> http://www.riverbankcomputing.com/static/Docs/sip4/sipref.html#using-sip
> It should be noted that I am working on a Mac - I know there are some 
> differences, but it's still UNIX and should work somehow.
> 
> Anyway, I copy-paste and create the Word.h header, write an 
> implementation in Word.cpp, the SIP wrapper Word.sip and the 
> configure.py script. I now run configure and make, creating the 
> following error:
> 
> ~/Desktop/SIP_example $ python configure.py
> ~/Desktop/SIP_example $ make
> c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o 
> sipwordcmodule.o sipwordcmodule.cpp
> c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o 
> sipwordWord.o sipwordWord.cpp
> c++ -headerpad_max_install_names -bundle -undefined dynamic_lookup -o 
> word.so sipwordcmodule.o sipwordWord.o -lword
> ld: library not found for -lword
> collect2: ld returned 1 exit status
> make: *** [word.so] Error 1
> ~/Desktop/SIP_example $
> 
> SWIG at least works nicely with C... Too bad I know so little about 
> compilers and libraries, I don't quite understand what the linker (ld) 
> is complaining about. The simplest tutorial should anyway work?

Not knowing C/C++ & linking is certainly something that will get you 
when trying to wrap libs written in these languages.

I'm on OSX myself, and can say that as a unixish system, it is rather 
friendly to self-compliation needs.

However, without having the complete sources & libs, I can't really 
comment much - the only thing that is clear from above is that the 
linker does not find the file

libword.dylib

which you of course need to have somewhere. The good news is that once 
you've teached the linker where to find it (using LDFLAGS or other 
means) you are (modulo debugging) done - SIP has apparently grokked your 
.sip-file.

Of course you also must make the library available at runtime. So it 
must be installed on a location (or that location given with 
DYLD_LIBRARY_PATH) where the dynamic loader will find it.

Diez



More information about the Python-list mailing list