链接错误:Windows上使用MinGW的Boost库
Linking Error: Boost Library on Windows using MinGW
我使用的是Windows 7 64x,并安装了MinGW。
我的目标是在Eclipse上使用boost库(这里:boost_program_options
)。
boost库已正确安装,我可以在C:MinGWboost_1_53_0stagelib
libboost_program_options-vc90-mt-gd-1_53.lib
我现在尝试通过转到Properties -> C/C++ Build -> Settings -> MinGW C++ Linker -> Libraries
:
这里我输入Library Search Path
(-L
): C:MinGWboost_1_53_0stagelib
对于Libraries
(-l
): boost_program_options-vc90-mt-gd-1_53
当尝试构建时,我得到以下错误消息:
11:06:54 **** Build of configuration Debug for project AP ****
make all
Building file: ../src/HW1EX1.cpp
Invoking: GCC C++ Compiler
g++ -I"C:MinGWboost_1_53_0" -I"C:MinGWboost_1_53_0boostprogram_options" -I"C:MinGWboost_1_53_0boost" -I"C:MinGWboost_1_53_0boostprogram_optionsdetail" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/HW1EX1.d" -MT"src/HW1EX1.d" -o "src/HW1EX1.o" "../src/HW1EX1.cpp"
Finished building: ../src/HW1EX1.cpp
Building target: AP.exe
Invoking: MinGW C++ Linker
g++ -LC:MinGWboost_1_53_0stagelib -static-libgcc -o "AP.exe" ./src/HW1EX1.o -lboost_program_options-vc90-mt-gd-1_53
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lboost_program_options-vc90-mt-gd-1_53
collect2: ld returned 1 exit status
make: *** [AP.exe] Error 1
11:06:57 Build Finished (took 3s.80ms)
有谁知道我可能做错了什么吗?感谢您的宝贵时间
您显然已经下载了使用Microsoft Visual c++编译器编译的二进制发行版(...-vc90-...
是一个提示)。或者也许你已经自己构建了它,但你是用Microsoft Visual c++ Compiler完成的。您必须使用MinGW从源代码构建Boost,因为您不能混合由不同的c++编译器生成的c++代码。换句话说,在您的情况下,您不能使用MinGW链接到由Microsoft Visual c++ Compiler生成的库。
另外,我怀疑-LC:MinGWboost_1_53_0stagelib
不会工作,因为有反斜杠,它没有引号。所以应该是-L"C:MinGWboost_1_53_0stagelib"
或者-LC:/MinGW/boost_1_53_0/stage/lib
。我更喜欢第二种变体,所以试着把向后斜杠改成向前斜杠,看看效果如何。还要仔细检查libboost_program_options-mgw46-1_53.a
是否真的在C:MinGWboost_1_53_0stagelib
中
- 如何在 Linux for Windows 上通过 MinGW 构建静态 ICU 的 Boost
- Boost::process on Windows - with MinGW?
- 静态链接再次链接boost.test和cmake在Windows上的mingw
- 使用由 Mingw 5.3 编译的 boost ASIO 库使用 QT 时出错
- 如何使用BOOST_THREAD_WIN32-MT-S(与mingw交叉键)来构建Boost
- 尝试在Visual Studio工作时使用CLION的Boost 1.69.0,但给出了奇怪的MINGW错误
- 如何将 vcpkg boost 与 MinGW 联系起来
- cmake FindBoost在Windows上使用MinGW构建时找不到Boost库
- 在Windows和Linux上使用Boost/ASIO在MingW中使用Boost/ASIO进行故障
- MinGW + Boost:未定义对"WSAStartup@8"的引用
- Boost 1.49/1.50/1.51 ASIO with MinGW & GCC 4.7.0 中的转换错误
- 将Boost库包含到标准MinGW路径中
- 使用MinGW与ICU建立Boost
- 链接CodeBlocks中的Boost库(使用MinGW)
- 对 MinGW-w64 gcc 上的 boost::random::random_device 构造函数和析构函数的未定
- 如何使用MinGW构建Boost 1.55
- Boost子图复制构造函数不适用于Qt 5.0.2和MinGW
- Boost(1.50.0)线程库与MinGW的链接
- mingw-w64无法链接到boost
- Mingw和Boost::Log:构建琐碎的示例失败