【发布时间】:2021-03-29 06:57:41
【问题描述】:
我正在尝试通过在 cygwin 上使用 mingw 来编译 LeapMotion API 的示例
当我使用 mingw64 编译时,它工作正常:
x86_64-w64-mingw32-g++ -s -I ../include -L ../lib/x64/ ExampleConnection.cpp -lLeapC PollingSample.cpp -oPollingSample
但如果我切换到 32 位:
i686-w64-mingw32-g++ -s -I ../include -L ../lib/x86/ ExampleConnection.cpp -lLeapC PollingSample.cpp -oPollingSample
我明白了:
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0x31): undefined reference to `LeapCreateConnection'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0x52): undefined reference to `LeapOpenConnection'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0xb5): undefined reference to `LeapCloseConnection'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0xe7): undefined reference to `LeapDestroyConnection'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0xfd): undefined reference to `LeapDestroyConnection'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0x16a): undefined reference to `LeapOpenDevice'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0x1d2): undefined reference to `LeapGetDeviceInfo'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0x205): undefined reference to `LeapGetDeviceInfo'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0x26d): undefined reference to `LeapCloseDevice'
/usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: /tmp/ccg2UNs3.o:ExampleConnection.cpp:(.text+0x4ac): undefined reference to `LeapPollConnection'
collect2: error: ld returned 1 exit status
我尝试更改命令字符串中 -lLeapC 的位置,并颠倒 .cpp 文件的顺序,但总是遇到相同的错误。
【问题讨论】:
-
您是否拥有正确的 32 库 (
libLeapC.a/libLeapC.dll.a)? -
/lib/x86 中只有 LeapC.lib 和 LeapC.dll,文件名与 /lib/x64 中相同
-
.lib 通常表示 MSVC。 MinGW 将 .a 用于静态库,将 .dll.a 用于共享库(连同 .dll)。
-
但 64 位版本运行良好,文件名相同
-
你能检查一下 DLL 文件导出了哪些符号(例如使用
pexports)吗?
标签: linker mingw undefined-reference