dlltool 因 python27.def 文件而失败

dlltool fails with python27.def file

我想从 python27.dll (C:Windows/SysWOW64)

创建 libpython27.a

我linux:

/usr/i686-w64-mingw32/bin/dlltool  -A --dllname python27.dll --def python27.def --output-lib libpython27.a
/usr/i686-w64-mingw32/bin/dlltool: Syntax error in def file python27.def:11

运行 dlltool 与 -v,我得到:

/usr/i686-w64-mingw32/bin/dlltool: Using file: /usr/i686-w64-mingw32/bin/as
/usr/i686-w64-mingw32/bin/dlltool: Processing def file: python27.def
��/usr/i686-w64-mingw32/bin/dlltool: Syntax error in def file python27.def:11
/usr/i686-w64-mingw32/bin/dlltool: Processed def file
/usr/i686-w64-mingw32/bin/dlltool: Processing definitions
/usr/i686-w64-mingw32/bin/dlltool: Processed definitions
/usr/i686-w64-mingw32/bin/dlltool: Creating library file: libpython27.a
/usr/i686-w64-mingw32/bin/dlltool: run: /usr/i686-w64-mingw32/bin/as   -o dlumbh.o dlumbh.s
/usr/i686-w64-mingw32/bin/dlltool: run: /usr/i686-w64-mingw32/bin/as   -o dlumbt.o dlumbt.s
/usr/i686-w64-mingw32/bin/dlltool: Created lib file

如您所见,我收到 python27.def 文件的语法错误,但 libpython27.a 已生成。

我创建了 python27.def 如下:(在 Windows)

python27.def的内容:

; .text   : RVA: 00001000, File offset: 00000400
; .rdata  : RVA: 000e7000, File offset: 000e6000
; .data   : RVA: 001b9000, File offset: 001b7e00
; .rsrc   : RVA: 00214000, File offset: 00209200
; .reloc  : RVA: 00215000, File offset: 00209a00
; Reading exports from section: .rdata
; Export table: python27.dll
; Ordinal base: 1
; Ordinal table RVA: 001b3300
; Name table RVA: 01b22b4
; Export address table RVA: 001b1268
LIBRARY python27.dll
EXPORTS
PyAST_Compile ; .text ; RVA 000c1a03
PyAST_FromNode ; .text ; RVA 000b394f
PyArena_AddPyObject ; .text ; RVA 000d4279
PyArena_Free ; .text ; RVA 000d4211
PyArena_Malloc ; .text ; RVA 000d424f
PyArena_New ; .text ; RVA 000d41bd
PyArg_Parse ; .text ; RVA 000cb1d6
PyArg_ParseTuple ; .text ; RVA 000cb218
PyArg_ParseTupleAndKeywords ; .text ; RVA 000ccb89
PyArg_UnpackTuple ; .text ; RVA 000cd191
PyArg_VaParse ; .text ; RVA 000cb25a
PyArg_VaParseTupleAndKeywords ; .text ; RVA 000ccc5c
PyBaseObject_Type DATA ; .data ; RVA 001d4728
PyBaseString_Type DATA ; .data ; RVA 001d8058
PyBool_FromLong ; .text ; RVA 00065ad7
PyBool_Type DATA ; .data ; RVA 001e6470
PyBuffer_FillContiguousStrides ; .text ; RVA 000631b8
PyBuffer_FillInfo ; .text ; RVA 0006320a
PyBuffer_FromContiguous ; .text ; RVA 00062f13
PyBuffer_FromMemory ; .text ; RVA 00065e2a
PyBuffer_FromObject ; .text ; RVA 00065dac
...
...

我创建 python27.def 的过程有问题吗?

注意:下面有一个libpython27.a,但我读了一些评论说link 反对在[=54] 中交叉编译一个python 扩展模块是行不通的=].

谢谢!

最后,我安装了 gendef(来自 win-builds)并创建了 python27.def

.\gendef.exe C:\Windows\SysWOW64\python27.dll

然后,在Linux中,我运行 dlltool成功地创建了libpython27.a:

i686-w64-mingw32-dlltool -A --dllname python27.dll --def python27.def --output-lib libpython27.a

libpython27.a 的大小 (gendef):774580

libpython27.a 的大小(使用 pexports 失败):1470

win-builds