embedded python on mac - linking problem

  • Thread starter Krzysztof Kobus
  • Start date
K

Krzysztof Kobus

Hi,

I have a problem with linking python module with my application on mac in order to make the module available in "embedded python".

My python module is contained in j3kmodule.cxx file and module initialization function is exported in j3kmodule.h

j3kmodule.h:
------------
PyMODINIT_FUNC PyInit_j3k(void);


j3kmodule.cxx:
--------------
PyMODINIT_FUNC
PyInit_j3k(void)
{
PyObject *m = NULL;

if ((m = PyModule_Create(&j3k_module)) == NULL)
return NULL;

return m;
}


Then in my application in KkPython.cxx file I have:

KkPython.cxx:
-------------

#include "j3kmodule.h"

/* Add a builtin module, before Py_Initialize */
PyImport_AppendInittab("j3k", PyInit_j3k);


I link my application with the module and get following linking error on mac although on open suse linux exactly the same procedure works fine:

g++ -headerpad_max_install_names -o ../../bin/render.app/Contents/MacOS/render main.o KkPython.o -lkkbase -L/Users/kk/dev/J3K/trunk/j3ksrc/examples/render/../../lib/ -lQtSolutions_PropertyBrowser-2.5 -lpython3.1 /Users/kk/dev/J3K/trunk/j3ksrc/python/modules/build/lib.macosx-10.3-i386-3.1/j3k.so -framework OpenGL -framework AGL
ld: warning in /Users/kk/dev/J3K/trunk/j3ksrc/python/modules/build/lib.macosx-10.3-i386-3.1/j3k.so, file is not of required architecture
Undefined symbols:
"_PyInit_j3k", referenced from:
_PyInit_j3k$non_lazy_ptr in KkPython.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [../../bin/render.app/Contents/MacOS/render] Error 1


I appreciate any hints,

best greetings,

Krzysztof Kobus
 
D

Diez B. Roggisch

Krzysztof said:
Hi,

I have a problem with linking python module with my application on mac in order to make the module available in "embedded python".

My python module is contained in j3kmodule.cxx file and module initialization function is exported in j3kmodule.h

j3kmodule.h:
------------
PyMODINIT_FUNC PyInit_j3k(void);


j3kmodule.cxx:
--------------
PyMODINIT_FUNC
PyInit_j3k(void)
{
PyObject *m = NULL;

if ((m = PyModule_Create(&j3k_module)) == NULL)
return NULL;

return m;
}


Then in my application in KkPython.cxx file I have:

KkPython.cxx:
-------------

#include "j3kmodule.h"

/* Add a builtin module, before Py_Initialize */
PyImport_AppendInittab("j3k", PyInit_j3k);


I link my application with the module and get following linking error on mac although on open suse linux exactly the same procedure works fine:

g++ -headerpad_max_install_names -o ../../bin/render.app/Contents/MacOS/render main.o KkPython.o -lkkbase -L/Users/kk/dev/J3K/trunk/j3ksrc/examples/render/../../lib/ -lQtSolutions_PropertyBrowser-2.5 -lpython3.1 /Users/kk/dev/J3K/trunk/j3ksrc/python/modules/build/lib.macosx-10.3-i386-3.1/j3k.so -framework OpenGL -framework AGL
ld: warning in /Users/kk/dev/J3K/trunk/j3ksrc/python/modules/build/lib.macosx-10.3-i386-3.1/j3k.so, file is not of required architecture
Undefined symbols:
"_PyInit_j3k", referenced from:
_PyInit_j3k$non_lazy_ptr in KkPython.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [../../bin/render.app/Contents/MacOS/render] Error 1


I appreciate any hints,

The missing symbol looks like a C++-symbol - but Python is C. Do you
maybe miss the

extern "C"

declaration.

Diez
 

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

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top