开发者

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 Enth开发者_开发知识库ought python contains such a file. I would like to create one for the more common distributions which don't contain it.


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


I'm not sure how helpful you find this, but at the bottom of the page you linked to there's a link to here - Where it says:

Do not use MinGW-w64. As you will notice, the MinGW import library for Python (e.g. libpython27.a) is omitted from the AMD64 version of Python. This is deliberate. Do not try to make one using dlltool. There is no official MinGW-w64 release yet, it is still in "beta" and considered unstable, although you can get a 64-bit build from e.g. TDM-GCC. There have also been issues with the mingw runtime conflicting with the MSVC runtime; this can happen from places you don't expect, such as inside runtime libraries for g++ or gfortran. To stay on the safe side, avoid MinGW-w64 for now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜