dlltool失败了python27.def文件

问题描述 投票:0回答:1

我想从python27.dll(C:Windows / SysWOW64)创建libpython27.a

该linych:

/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

用-v运行dlltool,我得到:

/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中)

  • 得到了pexports-0.47-mingw32-bin.tar.xz(应该支持32位和64位)
  • 运行pexports.exe -v。\ python27.dll> python27.def

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但是我读了一些注释,它不能用于链接以在linux中交叉编译python扩展模块。

谢谢!

python cross-compiling swig extension-modules
1个回答
0
投票

最后,我安装了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

© www.soinside.com 2019 - 2024. All rights reserved.