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

C++ 链接使用i686-w64-mingw32编译的POCO库时出错,c++,linker,linker-errors,poco,C++,Linker,Linker Errors,Poco,我正在使用从sf下载的i686-w64-mingw32编译POCO库。编译库并创建libPoco*.a文件(带有一些警告)。 现在,当我想使用这些文件时(例如,在一个将字符串转换为整数的小样本项目中),链接器抛出错误,说:/Debug/main.o:main.cpp:(.text+0xab):未定义对“imp_uzn4poco12numberparser5parserkss”的引用。 奇怪的是,如果我使用TDM-MinGW-4.7.1对双方(lib和test-app)进行编译,一切都会很好 我尝

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

奇怪的是,如果我使用TDM-MinGW-4.7.1对双方(lib和test-app)进行编译,一切都会很好

我尝试在两种编译中设置“-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

我使用ar和objDump来查看链接器所抱怨的类的库和对象文件的内容。似乎对象文件中的符号名为“\u ZN4POC12NumberParser5Parseerkss”,而链接器为“\u imp\uU2UZN4POC12NumberParser5Parseerkss”提供了undef ref错误。11警告与可见性属性相关:C:/poco/Foundation/src/inffast。C:324:1:警告:此配置中不支持可见性属性;忽略[-Wattributes]可能需要定义一些预处理器?(-D)好吧,好吧,好吧!我修好了。链接器正在查找“\u impl\u xxxx”符号,而静态库中的符号是“xxxx”。我必须在客户端应用程序中定义“POCO_STATIC”。就这些!