Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building 64bit libpython27.a using cygwin, dlltool

I'm trying to build a python extension DLL on a 64bit Win7 machine using cygwin (as cygwin only run as 32bit process, this is actually cross-compiling).

I created libpython27.a myself from python27.dll using dlltool (as explained, for example, here), but the build fail during the linker phase saying
skipping incompatible c:\Python27\libs/libpython27.a when searching for -lpython27
This is exactly the error reported here (where the guy ended up moving to MSVC compiler...).

More info:
- Active Python 2.7.2, win64, x64
- latest version of cygwin, using the /usr/bin/x86_64-w64-mingw32-g++.exe compiler

Does anyone know if this is supported?
Is there way to use dlltool which I miss here?

(I did found here the guidance to use
dlltool --as-flags=--64 -m i386:x86-64 -k -l libpython27.a -d python.def
but when doing so I got "invalid bfd target" error from dlltool)

Thanks!

Update: I believe it can be done because Enthought python contains such a file. I would like to create one for the more common distributions which don't contain it.

like image 958
Uri Cohen Avatar asked Nov 13 '22 17:11

Uri Cohen


1 Answers

The problem is that you are using the 32 bit dlltool. Probably in C:\MinGW\bin instead of C:\MinGW64\bin. You can change your path, or run the 64 bit tool specifically as such:

C:\MinGW64\bin\dlltool -v --dllname python27.dll --def python27.def --output-lib libpython27.a
like image 64
John Cornwell Avatar answered Dec 17 '22 21:12

John Cornwell