与使用 i686-w64-mingw32 编译的 POCO 库链接时出错
Error when linking with POCO library compiled with i686-w64-mingw32
我正在使用从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
相关文章:
- 读取文件的最后一行并输入到链接列表时出错
- C++ 创建包含链表和字符串的对象的链接列表时出错
- 在发布模式下启动使用库的静态链接编译的应用程序时出错
- 编译时出错 - 链接.cpp和头文件
- 将 boost 与 Visual Studio 和 vcpkg 链接时出错
- 获取链接 创建flyweight_pattern时出错
- 从Qt5链接MySQL时出错
- 迭代器关系运算符出错(带单独链接和迭代器的自定义哈希表)
- 与 glfw3 链接时出错
- GNU 链接器:如果头文件中的指针被声明为 NULL 和/或 extern,则出错
- 可能的 GCC 链接器错误会导致将弱符号和局部符号链接在一起时出错
- 使用提升库和 clion 链接时出错
- 在 Fedora 27 中构建 GLFW 时链接期间出错
- 将 CLANG 构建的可执行文件与 G++-v6 构建的 Boost 库链接时出错
- 链接 gtest 项目时出错
- 链接webrtc本机时出错,因为未定义对具有std::string的方法的引用
- wxwidget 3.1.2 代码块 17.04 在链接步骤中出错
- 链接Firebase C (分析)库时出错
- 在Windows上使用GCC的链接时间优化构建wxWidgets DLL时出错
- 链接外部变量 c++ 时出错