Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > embedded python on mac - linking problem

Reply
Thread Tools

embedded python on mac - linking problem

 
 
Krzysztof Kobus
Guest
Posts: n/a
 
      01-05-2010
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



 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      01-05-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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
readline for mac python? (really, reproducing mac python packages) K Richard Pixley Python 3 01-03-2012 05:32 AM
Embedded python adding variables linking to C++-Variables / callbacks iwl Python 3 12-07-2006 08:54 PM
Linking problems under irix6 with embedded Python2.4 Wolfgang Python 0 03-17-2005 05:57 AM
How to display images embedded in e-mail as embedded, not attachments Jim Firefox 4 12-11-2004 05:36 AM
Linking problem after porting to Mac OSX (_compress/_uncompress) Daniel Wetzler C++ 0 07-19-2003 04:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57