与使用 i686-w64-mingw32 编译的 POCO 库链接时出错

Error when linking with POCO library compiled with i686-w64-mingw32

本文关键字:链接 出错 POCO i686-w64-mingw32 编译      更新时间:2023-10-16

我正在使用从sf下载的i686-w64-mingw32来编译POCO库。编译库并创建libPoco*.a文件(有一些警告)。现在,当我想使用这些文件时(例如,在一个将字符串转换为整数的小型示例项目中),链接器会抛出错误,说:./Debug/main.o:main.cpp:(.text+0xab):对"imp__ZN4Poco12NumberParser5parseERKSs"的未定义引用

奇怪的是,如果我使用 TDM-MinGW-4.7.1 为双方(lib 和测试应用程序)进行编译,一切都很好!

我尝试在两个编译上设置"-march=i386;-m32",但没有运气。这是我尝试构建测试应用程序时链接器的日志:

g++ -o ./Debug/testpoco @"testpoco.txt" -L. -Lc:/poco/lib/  -lPocoFoundationmtd  -v
Using built-in specs.
COLLECT_GCC=g++
...
Target: i686-w64-mingw32
...
Thread model: win32
gcc version 4.8.1 (rev5, Built by MinGW-W64 project)
...
COLLECT_GCC_OPTIONS='-o' './Debug/testpoco.exe' '-L.' '-Lc:/poco/lib/' '-v' '-shared-libgcc' '-mtune=generic' '-march=i686'
...
./Debug/main.o:main.cpp:(.text+0xab): undefined reference to `_imp___ZN4Poco12NumberParser5parseERKSs'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [Debug/testpoco] Error 1
testpoco.mk:77: recipe for target 'Debug/testpoco' failed
通常,

只有当您没有正确链接库时,才会引发此类错误。你确定libPocoFoundationmtd.a包含这个函数吗?如果这样做,编译这些库时会显示哪些警告。也检查这些

确保定义了所有需要的预处理器符号!(-D) 例如:POCO_STATIC