[C++-sig] Problems importing a c++ shared library
t_spens
t_spens at yahoo.com
Fri May 18 02:02:21 CEST 2007
ImportError: dynamic module does not define init function (initlibhello) - I
have no idea why I'm getting this error.
I'm using gcc to create my library libhello.so from the .cpp file below
Here are my gcc arguments:
gcc -g -Wall -I ../../../usr/include/boost -I ../../../usr/include/python2.5
-c hello.cpp -o hello.o
gcc -shared -fPIC -g -Wall -I ../../../usr/include/boost -I
../../../usr/include/python2.5 -L /usr/lib -lstdc++ -lboost_python -o
libhello.so hello.o
#include <iostream>
using namespace std;
void print(char * stringToPrint){cout << stringToPrint << endl;}
int main ()
{
print("hello from c++");
return 0;
}
#include <boost/python.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(hello)
{
def("print", print);
}
~/pythonScripts$ python
Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libhello
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initlibhello)
>>>
Any ideas?
--
View this message in context: http://www.nabble.com/Problems-importing-a-c%2B%2B-shared-library-tf3775017.html#a10674432
Sent from the Python - c++-sig mailing list archive at Nabble.com.
More information about the Cplusplus-sig
mailing list