trying to use swig for the first time

G

Gary Wilson Jr

....I have some C code (foo.c and foo.h) that I would like to be able to access
using python.

I've written my interface file (foo.i) like so:
%module foo
%{
#include "foo.h"
%}
%include "foo.h"

I then do the following on the command line:
$ swig -python foo.i
$ gcc -c foo.c foo_wrap.c -I /usr/include/python2.4
$ ld -shared foo.o foo_wrap.o -o _foo.so

Then when I try importing the module into python:
$ python -c "import foo"
Traceback (most recent call last):
File "<string>", line 1, in ?
File "foo.py", line 5, in ?
import _foo
ImportError: ./_foo.so: undefined symbol: EVP_DecodeBlock

Now, EVP_DecodeBlock can be found in /usr/include/openssl/evp.h:
int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);

And evp.h in included in foo.h:
#include <openssl/evp.h>

What am I doing wrong here?
Do I need to include more in the interface file?

I tried adding the EVP_DecodeBlock declaration to the interface file like so:
%module foo
%{
#include "foo.h"
extern int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
%}
%include "foo.h"
extern int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);

But this led to the exact same error when trying to import the python module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top