【问题标题】:Linking Error: Boost Library on Windows using MinGW链接错误:使用 MinGW 的 Windows 上的 Boost 库
【发布时间】:2013-04-24 09:18:44
【问题描述】:

我使用的是 Windows 7 64x 并安装了 MinGW。

我的目标是在 Eclipse 上使用 boost 库(这里:boost_program_options)。

boost库安装正确,我可以在C:\MinGW\boost_1_53_0\stage\lib下看到文件libboost_program_options-vc90-mt-gd-1_53.lib

我现在尝试通过转到Properties -> C/C++ Build -> Settings -> MinGW C++ Linker -> Libraries 来在 Eclipse 中链接它:

我在这里输入Library Search Path (-L):C:\MinGW\boost_1_53_0\stage\lib 对于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:\MinGW\boost_1_53_0" -I"C:\MinGW\boost_1_53_0\boost\program_options" -I"C:\MinGW\boost_1_53_0\boost" -I"C:\MinGW\boost_1_53_0\boost\program_options\detail" -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:\MinGW\boost_1_53_0\stage\lib -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)

有人知道我做错了什么吗?

感谢您的宝贵时间

【问题讨论】:

    标签: c++ eclipse boost linker mingw


    【解决方案1】:

    您显然已经下载了使用 Microsoft Visual C++ 编译器编译的二进制发行版(...-vc90-... 是一个提示)。或者,也许您是自己构建的,但您是使用 Microsoft Visual C++ 编译器完成的。您必须使用 MinGW 从源代码构建 Boost,因为您不能混合由不同 C++ 编译器生成的 C++ 代码。换句话说,在您的情况下,您无法使用 MinGW 链接到 Microsoft Visual C++ Compiler 生成的库。

    此外,我怀疑-LC:\MinGW\boost_1_53_0\stage\lib 不起作用,因为有反斜杠并且没有被引用。所以它应该是-L"C:\MinGW\boost_1_53_0\stage\lib"-LC:/MinGW/boost_1_53_0/stage/lib。我更喜欢第二种变体,所以尝试将反斜杠更改为正斜杠,看看效果如何。还要仔细检查libboost_program_options-mgw46-1_53.a 是否真的在C:\MinGW\boost_1_53_0\stage\lib 中。

    【讨论】:

    • 感谢您指出这一点,我已将 boost_program_options-vc90-mt-gd-1_53 替换为 boost_program_options-mgw46-1_53 但我仍然收到相同的错误消息。有人有其他想法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-18
    • 1970-01-01
    相关资源
    最近更新 更多