embedded python on mac - linking problem

Diez B. Roggisch deets at nospam.web.de
Tue Jan 5 16:39:05 EST 2010


Krzysztof Kobus schrieb:
> 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



More information about the Python-list mailing list