ImportError: undefined symbol

Hugues Demers hdemers at venus.astro.umontreal.ca
Fri Jan 19 11:22:22 EST 2001


Hi,

This question must have come up many times, but I cannot find any answers
in the official documentation or the FAQ or this newsgroup. So here it is.

I'm writing a small extension in C++ that call functions from a C++ library
(GALib). My extension looks like this (it's a test):

#include <ga/ga.h>
#include <math.h>
#include <Python.h>

float objective( GAGenome & );
void gaFit();

extern "C" {

static PyObject* fit( PyObject* self, PyObject* args )
{
    gaFit();
    Py_INCREF( py_None );
    return Py_None;
}

static PyMethodDef gaPhotoMethods[] = {
    {"fit", fit, METH_VARARGS},
    {NULL, NULL}
};

static initgaPhoto()
{
    (void) Py_InitModule( "gaPhoto", gaPhotoMethods );
}

} // End of extern "C"

void gaFit()
{
    // Call to C++ library
}

void objective( GAGenome& c )
{
    // do stuff
}

My setup file is written like this:

*shared*

gaPhoto gaPhotomodule.cpp -L/usr/local/lib -lga 

When in Python I import the module I get this error:

ImportError: ./gaPhotomodule.so: undefined symbol: __ls__7ostreamPCc

Can someone help me?

Thanks
Hugues



More information about the Python-list mailing list