在Linux上交叉编译Win64二进制文件

时间:2017-11-15 23:14:03

标签: c++ linux cross-compiling linker-errors win64

我试图使用x86_64-w64-mingw32-g++实用程序在我的Debian机器上编译Win64二进制文件。即使我将库传递给链接器,我也遇到了undefined reference *链接器错误的问题:

# /usr/bin/x86_64-w64-mingw32-g++ -lgdi32 -luser32 -lkernel32 -lcomctl32 -m64 -o main.exe main.cpp code.obj
/tmp/ccSKB1pW.o:main.cpp:(.text+0x82a): undefined reference to `__imp_CreateCompatibleDC'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x847): undefined reference to `__imp_CreateCompatibleBitmap'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x85f): undefined reference to `__imp_SelectObject'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x871): undefined reference to `__imp_CreateSolidBrush'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x8da): undefined reference to `__imp_BitBlt'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x8ee): undefined reference to `__imp_SelectObject'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x8fe): undefined reference to `__imp_DeleteObject'
/tmp/ccSKB1pW.o:main.cpp:(.text+0x90e): undefined reference to `__imp_DeleteDC'
collect2: error: ld returned 1 exit status

我无法在线找到有关此问题的更多信息。知道为什么它没有找到库中的符号吗?

编辑:据我所知,debian软件包提供了一个GDI库:

# dpkg -L mingw-w64-x86-64-dev | grep gdi32
/usr/x86_64-w64-mingw32/lib/libgdi32.a

此外,我能够在库文件中找到符号:

# objdump -t /usr/x86_64-w64-mingw32/lib/libgdi32.a | grep CreateCompat
[  7](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000000000 CreateCompatibleDC
[  8](sec  5)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000000000 __imp_CreateCompatibleDC
[  7](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000000000 CreateCompatibleBitmap
[  8](sec  5)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000000000 __imp_CreateCompatibleBitmap

0 个答案:

没有答案