简体   繁体   English

在eclipse cdt中找不到库文件

[英]cannot not find library files in eclipse cdt

properties/C/C++ Build/Settings GCC C++ Linker/Libraries properties / C / C ++构建/设置GCC C ++链接器/库

Under libraries(-I) I have libbost_system libbost_filesystem ... and under Library search path(-L) I have /home/etobkru/boost_1_43_0/boostBinaries/lib 在库(-I)下我有libbost_system libbost_filesystem ...并且在库搜索路径(-L)下我有/ home / etobkru / boost_1_43_0 / boostBinaries / lib

but when I compile I get g++ -L/home/etobkru/boost_1_43_0/boostBinaries/lib/ -o"searchDirs" ./main.o -llibboost_system -llibboost_filesystem -llibboost_regex /usr/lib/gcc/i586-suse-linux/4.1.2/../../../../i586-suse-linux/bin/ld: cannot find -llibboost_system 但是当我编译时,我得到g ++ -L / home / etobkru / boost_1_43_0 / boostBinaries / lib / -o“searchDirs”./ main.o -llibboost_system -llibboost_filesystem -llibboost_regex /usr/lib/gcc/i586-suse-linux/4.1 .2 /../../../../ i586-suse-linux / bin / ld: 找不到-llibboost_system

I have tried with libbost_system.so and libbost_system.a but i get the same error. 我尝试过libbost_system.so和libbost_system.a,但我得到了同样的错误。 What am I doing wrong and why cant eclipse find the files. 我做错了什么以及为什么eclipse无法找到文件。 Because they are there? 因为他们在那里?

You don't need the "lib" part in the name. 您不需要名称中的“lib”部分。 Just link with 只需链接

-lboost_system -lboost_filesystem -lboost_regex

I think this is similar to /usr/bin/ld: cannot find -llibeststring.a 我认为这类似于/ usr / bin / ld:找不到-llibeststring.a

Did you try -lboost_system ? 你试过-lboost_system吗? The -l option doesn't expect the leading lib or the trailing .a or .so . -l选项不期望前导lib或尾随.a.so

Actually after much frustration I decided to read the man page for ld! 实际上经过很多挫折后我决定阅读ld的手册页!

l namespec --library=namespec Add the archive or object file specified by namespec to the list of files to link. l namespec --library = namespec将namespec指定的存档或目标文件添加到要链接的文件列表中。 This option may be used any number of times. 此选项可以使用任意次。 If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a. 如果namespec的格式为:filename,ld将在库路径中搜索名为filename的文件,否则它将在库路径中搜索名为libnamespec.a的文件。

since my specific library was something along the lines of myfoobar.dll nothing worked until I realized I wanted ld to use the actual filename. 因为我的特定库是myfoobar.dll的一些东西,直到我意识到我希望ld使用实际的文件名之前没有任何工作。 As others have posted with screenshots how to add the library to the linker all I needed to do was change 'myfoobar' in the field to ':myfoobar.dll' and it worked fine. 正如其他人发布截图一样,如何将库添加到链接器,我需要做的就是将字段中的'myfoobar'更改为':myfoobar.dll',它运行正常。

You should use the ':' to get really specific on the filename to search for and stay away from the default file name formatting that is expected without it. 您应该使用':'来确定要搜索的文件名,并远离默认的文件名格式,如果没有它。 Hope this eases frustration. 希望这可以减轻挫败感。

Krusty, 香酥,

我知道它有点事后,但您可以尝试-l:libbost_system.so并且它将查找具有该名称的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM