2013-04-24 36 views
3

我使用Windows 7 64x并安装了MinGW。链接错误:使用MinGW在Windows上启动库

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

Boost库安装是否正确,我可以看到该文件libboost_program_options-vc90-mt-gd-1_53.libC:\MinGW\boost_1_53_0\stage\lib

我现在尝试去在Eclipse中链接这Properties -> C/C++ Build -> Settings -> MinGW C++ Linker -> Libraries

在这里,我为Library Search Path-L)输入:C:\MinGW\boost_1_53_0\stage\libLibraries-l):boost_program_options-vc90-mt-gd-1_53

当试图建立,我得到以下错误messag e:

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) 

有没有人知道我可能会做错什么?

谢谢您的时间

回答

2

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

此外,我怀疑-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

+0

感谢您指出这一点,我用boost_program_options-mgw46-1_53替换了boost_program_options-vc90-mt-gd-1_53,但仍然收到相同的错误消息。任何人有任何其他想法? – user1431340 2013-04-24 14:15:53

+0

更新,看看。 – 2013-04-24 16:00:19

+0

它工作?这不是工作或我 – 2016-10-13 07:37:39