[英]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). 我正在尝试使用cygwin在64位Win7机器上构建一个python扩展DLL(因为cygwin只运行32位进程,这实际上是交叉编译)。
I created libpython27.a myself from python27.dll using dlltool (as explained, for example, here ), but the build fail during the linker phase saying 我使用dlltool从python27.dll创建了libpython27.a(例如, 在这里解释),但是在链接器阶段说构建失败了
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...). 这正是这里报告的错误(那个人最终转向MSVC编译器......)。
More info: 更多信息:
- Active Python 2.7.2, win64, x64 - Active Python 2.7.2,win64,x64
- latest version of cygwin, using the /usr/bin/x86_64-w64-mingw32-g++.exe compiler - 使用/usr/bin/x86_64-w64-mingw32-g++.exe编译器的最新版cygwin
Does anyone know if this is supported? 有谁知道这是否支持?
Is there way to use dlltool which I miss here? 有没有办法使用我想念的dlltool?
(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) 但是当这样做时,我从dlltool得到
"invalid bfd target"
错误)
Thanks! 谢谢!
Update : I believe it can be done because Enthought python contains such a file. 更新 :我相信它可以完成,因为Enthought python包含这样一个文件。 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. 问题是你使用的是32位dlltool。 Probably in C:\\MinGW\\bin instead of C:\\MinGW64\\bin.
可能在C:\\ MinGW \\ bin而不是C:\\ MinGW64 \\ bin。 You can change your path, or run the 64 bit tool specifically as such:
您可以更改路径,或者专门运行64位工具:
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.
不要使用MinGW-w64。 As you will notice, the MinGW import library for Python (eg libpython27.a) is omitted from the AMD64 version of Python.
正如您将注意到的,AMD的AMD64版本中省略了Python的MinGW导入库(例如libpython27.a)。 This is deliberate.
这是故意的。 Do not try to make one using dlltool.
不要尝试使用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 eg TDM-GCC.
目前还没有正式的MinGW-w64版本,它仍然处于“测试阶段”且被认为是不稳定的,尽管你可以从例如TDM-GCC获得64位版本。 There have also been issues with the mingw runtime conflicting with the MSVC runtime;
mingw运行时与MSVC运行时冲突也存在问题; this can happen from places you don't expect, such as inside runtime libraries for g++ or gfortran.
这可能发生在您不期望的地方,例如g ++或gfortran的运行时库内部。 To stay on the safe side, avoid MinGW-w64 for now.
为了保持安全,请立即避免使用MinGW-w64。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.