trying to use swig for the first time

Discussion in 'Python' started by Gary Wilson Jr, Jan 23, 2006.

  1. ....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.
     
    Gary Wilson Jr, Jan 23, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. flamesrock
    Replies:
    8
    Views:
    502
    Hendrik van Rooyen
    Nov 24, 2006
  2. Eric von Horst
    Replies:
    3
    Views:
    842
    Eric von Horst
    Feb 28, 2008
  3. manu
    Replies:
    4
    Views:
    258
  4. ofranko
    Replies:
    3
    Views:
    367
    osmium
    Jan 7, 2009
  5. bryanedds
    Replies:
    2
    Views:
    120
    M. Edward (Ed) Borasky
    Oct 1, 2006
Loading...

Share This Page