I'm experimenting Swig on python, to produce a wrapper around libxosd.
Using swig 1.3 (debian)
Using python 2.2
The point here is that I really want to do it the lazy way: I don't want to write anny interface code, and dig in .h file to find what to write. I know this may not be the best way, but I'm looking for a proof of concept.
So, I've this interface file:
#cat xosd.i
%module xosd
%{
#include "xosd.h"
%}
%include "xosd.h"
Generating _wrap file is OK. Compiliing xosd_wrap.c AND xosd.c is cool, as are .o and .so file.
xosd.c and xosd.h can be found in the current directory.
When running python -c "import xosd", I get:
import _xosd
ImportError: ./_xosd.so : undefined Symbol: XFreePixmap
It seems I got an issue in including some X11 header file. The error was not reported by either gcc or swig.
So, I perhaps have to wrap the X11 librairy , but I think it is a wrong solution.
As I said, I want to be lazy: I don't want to write a nice xosd.i interface file with just a few functions, which perhaps might work. I want to try the "%include .h file" option.
By the way, if this can not work, does anyone know a way to lazyly interface to c/c++ ?
I know a little about pyrex, but it requires you to write down a .pyx file, the interface.
I know that python is made to be easily extended to C/C++, but I don't want to write the wrapping C call.
I knwo that... i'm asking for a lot !
And, BTW, I know that, if I really want to be lazy, I could use the already existing pyosd :)
But, I do that in order to learn extending python in C/C++.
Any help would be...just great !
Thanks in advance,
OPQ
> When running python -c "import xosd", I get:
> import _xosd
> ImportError: ./_xosd.so : undefined Symbol: XFreePixmap
This has nothing to do with SWIG. When you link the extension, you need
to be sure to link it against any libraries it depends on; in this case,
I believe that XFreePixmap is found in libX11.so.
thanks for the very fast answer.
Indeed, I needed a simple
-L/usr/X11R6/lib -lX11 -lXaw in my gcc *.o compilation.
This really rocks.
>hope this helps
It did !
> -----Message d'origine-----
> De : ly...@knology.net [mailto:ly...@knology.net]
> Envoyé : mardi 4 mars 2003 17:08
> À : POYEN OP Olivier (DCL)
> Objet : RE: Lazy Swig User
>
>
>
> On Tue, 4 Mar 2003 16:38:48 +0100, "POYEN OP Olivier (DCL)"
> <Olivie...@clf-dexia.com> wrote :
>
> > Sorry for being so lame at C, but why does gcc not complain
> about that.
> > Because I'm able to build the _xosd.so without trouble, and without
> telling gcc to import any lib.
>
> Right. GCC is only partially linking your shared library
> (_xosd.so), and so
> unresolved symbols (such as XFreePixmap, in your case) are
> allowed. There
> may be an option for it to report any unresolved symbols --
> you'll have to
> check the manual pages.
>
> > Do I have to add -L libX11.so in the gcc *.o step, even if
> it is in the
> LibPath ?
>
> Yes, you would do something like this:
>
> gcc -shared -o _xosd.so *.o -L/usr/X11R6/lib -lX11 ...
>
> > BTW, thanks for answering
>
> No problem, hope this helps.
>