Je travaille sur une application écrite en C. Une partie de l'application devrait intégrer python et il y a mon problème actuel. J'essaie de lier ma source à la bibliothèque Python mais cela ne fonctionne pas. En utilisant MinGW, j'ai créé le fichier python26.a à partir de python26.lib avec dlltool et j'ai mis le fichier * .a en C:/Program Files (x86)/python/2.6/libs
.Comment lier C lib à python pour l'intégrer sous Windows?
Par conséquent, je compilez le fichier avec cette commande:
gcc -shared -o mod_python.dll mod_python.o "-LC:\Program Files (x86)\python\2.6\libs" -lpython26 -Wl,--out-implib,libmod_python.a -Wl,--output-def,mod_python.def
et je reçois ces erreurs:
Creating library file: libmod_python.a
mod_python.o: In function `module_init':
mod_python.c:34: undefined reference to `__imp__Py_Initialize'
mod_python.c:35: undefined reference to `__imp__PyEval_InitThreads'
... and so on ...
- Mon Python dossier "racine" est-
C:\Program Files (x86)\python\2.6
- Le Devsystem est a Windows Server 2008
- Informations GCC:
Reading specs from C:/Program Files (x86)/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug Thread model: win32 gcc version 3.4.5 (mingw-vista special r3)
Qu'est-ce que je fais mal? Comment je l'ai compilé et lié :-)?
Cheers, gregor
Edit: J'ai oublié d'écrire des informations sur mon installation Python: Il est l'installation de python.org officiel 2.6.1
... et comment je créé le fichier python.a:
dlltool -z python.def --export-all-symbols -v c:\windows\system32\python26.dll
dlltool --dllname c:\Windows\system32\python26.dll --def python.def -v --output-lib python26.a
Hmm ... Vous avez raison. Sur mon PC au travail, j'ai un 'libpython26.a'. Cela doit être nouveau dans la distribution Python 2.6.2? Parce qu'à la maison avec Python 2.6.1 je ne l'ai pas eu. Génial. Je dois changer votre réponse comme la bonne! – Gregor
Mise à jour courte: Cela fonctionne parfaitement! Merci beaucoup à tous. – Gregor