|
From: Brett C. <bre...@gm...> - 2007-05-18 07:33:53
|
Can SWIG wrap a static library with only the header files (no source
code for the linking stage, only the .a file)? I don't seem to be
able to make my swig-generated files link to the library.
I'm trying to create python wrappers for a C++-based static library
(SMILE, a free-as-in-beer library for Bayesian networks) for which I
don't have access to the source, only the .h header files and the .a
compiled static library code.
This is what I've tried so far:
1) created a modest pysmile.i file which just includes the smile.h library:
brett@boca:~/SMILE-GENIE/tests/swig/pysmile$ cat pysmile.i
%module pysmile
%{
/* Includes the header in the wrapper code */
#include "smile.h"
%}
/* Parse the header file to generate wrappers */
%include "smile.h"
2) Issued the following commands:
brett@boca:~/SMILE-GENIE/tests/swig/pysmile$ swig -c++ -python -o
pysmile_wrap.cpp pysmile.i
brett@boca:~/SMILE-GENIE/tests/swig/pysmile$ gcc -fPIC -c
pysmile_wrap.cpp -o pysmile_wrap.o -I/usr/include/python2.5
brett@boca:~/SMILE-GENIE/tests/swig/pysmile$ g++ pysmile_wrap.o
-L/usr/local/lib -lsmile -o _pysmile.so
3) I'm currently unable to make it link to the static library; while I
get no errors creating the wrapper, importing it into python gives me
this error:
ImportError: ./_pysmile.so: undefined symbol: _Z16EnableXdslFormatv
|