John Machin a écrit :

Jean-Baptiste PERIN wrote:

Hi,

I'm trying to make a windows dll reachable from a python script ..

and

I'm encountering troubles during link step ..

I use "lcc" to compile and link
I use python 2.3 under win XP

[snip]

Here are the errors :
---------------------
Error c:\...\plugins\hello.c 14 undefined reference to

__imp__Py_BuildValue

Error c:\...\plugins\hello.c 46 undefined reference to

__imp__Py_InitModule4 [snip]

return Py_BuildValue("i", 1);

[snip]

void __declspec(dllexport) inithello()
{
    (void)Py_InitModule3("hello", helloMethods, MHello__doc__);
Can anyone help me?


Yes. Option 1: *Maybe* you can help yourself. Have you not noticed from
the above that the compiler is magically prepending "__imp__" to the
names of external functions? However the .lib that comes with Python
won't have that "__imp__". You would have to bridge that gap, somehow.
Have you searched the lcc documentation? Are you prepared for the next
several problems that may arise?

Indeed, it's something I can't understand (the __imp__ stuff).. Nothing appear about that in the I have posted a question on lcc forum .. the author of lcc answered

"This happens because somewhere you are declaring the functions
Py_BuildValue
and
Py_InitModule

as __declspec(dllimport) "

He's right !!
He adviced me to change that ..
I don't want to make changes to python code .. so .. bye bye lcc

long life to gcc

By the way, lcc also *appears* to change "...Module3" to "...Module4"
:-)

this one is explainable to me .. it is due to the fact that both function are equivalent


in mod support.h:

#define Py_InitModule3(name, methods, doc) \
        Py_InitModule4(name, methods, doc, (PyObject *)NULL, \
                       PYTHON_API_VERSION)


Option 2: You have been helped already. There are two free compilers
which work quite well for developing extensions in C for win32
platforms; start reading here:

http://docs.python.org/inst/tweak-flags.html#SECTION000620000000000000000


I'm currently attracted by the cygwin solution .. that I find very sexy !! If I fail .. I will explore the MingW ..

Thank you very much for helping me ..
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to