SWIG & C Extensions, win32 & MinGW: undefined reference

Discussion in 'Python' started by newbie73, Dec 17, 2007.

  1. newbie73

    newbie73 Guest

    Going through the tutorial on http://swig.org, I created the example files
    (pasted below). After generating the _wrap file, I tried compiling (using
    mingw32) and received a lot of undefined reference compiler errors:

    ...\build\temp.win32-2.5\Release\example_wrap.o:example_wrap.c:(.text+0x670f):
    undefined reference to `_imp__PyExc_MemoryError'

    there are many other similar errors all prefaced with _imp__Py, so I am
    assuming there is a linker error with the python libraries. I have adjusted
    my PATH variable to include all the python directories (libs/dlls), so I am
    unclear what else I can try. Any suggestions?


    FILES FROM TUTORIAL:


    //example.c
    #include <time.h>
    double My_variable = 3.0;

    int fact(int n) {
    if (n <= 1) return 1;
    else return n*fact(n-1);
    }

    int my_mod(int x, int y) {
    return (x%y);
    }

    char *get_time()
    {
    time_t ltime;
    time(&ltime);
    return ctime(&ltime);
    }
    //***************************************************************

    //example.i
    %module example
    %{
    /* Put header files here or function declarations like below */
    extern double My_variable;
    extern int fact(int n);
    extern int my_mod(int x, int y);
    extern char *get_time();
    %}

    extern double My_variable;
    extern int fact(int n);
    extern int my_mod(int x, int y);
    extern char *get_time();
    //***************************************************************

    //setup.py
    from distutils.core import setup, Extension

    setup(name='example',
    version = '1.0',
    ext_modules=[
    Extension('example', ['example.c', 'example.i'])
    ])

    //***************************************************************
    --
    View this message in context: http://www.nabble.com/SWIG---C-Exte...-undefined-reference-tp14373972p14373972.html
    Sent from the Python - python-list mailing list archive at Nabble.com.
    newbie73, Dec 17, 2007
    #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. Sam Smith
    Replies:
    0
    Views:
    1,149
    Sam Smith
    Oct 18, 2004
  2. rhzehr
    Replies:
    4
    Views:
    1,106
    Mark McIntyre
    Apr 25, 2005
  3. Dom
    Replies:
    1
    Views:
    12,558
  4. Soren
    Replies:
    3
    Views:
    490
    Paul Melis
    Apr 29, 2008
  5. xeno fears
    Replies:
    1
    Views:
    489
    Martin v. Löwis
    Oct 4, 2009
Loading...

Share This Page