在 eclipse cdt 中找不到库文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2958137/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:48:06  来源:igfitidea点击:

cannot not find library files in eclipse cdt

c++eclipseboostlinker

提问by hidayat

properties/C/C++ Build/Settings GCC C++ Linker/Libraries

属性/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. What am I doing wrong and why cant eclipse find the files. Because they are there?

我已经尝试过 libbost_system.so 和 libbost_system.a,但我得到了同样的错误。我做错了什么,为什么 eclipse 找不到文件。因为他们在那里?

回答by Troubadour

You don't need the "lib" part in the name. Just link with

您不需要名称中的“lib”部分。只需链接

-lboost_system -lboost_filesystem -lboost_regex

回答by Mark B

I think this is similar to /usr/bin/ld: cannot find -llibeststring.a

我认为这类似于/usr/bin/ld: cannot find -llibeststring.a

Did you try -lboost_system? The -loption doesn't expect the leading lib or the trailing .aor .so.

你试了-lboost_system吗?该-l选项不期望前导 lib 或尾随.aor .so

回答by JnBrymn

I know it's a little after the fact, but you can try -l:libbost_system.so and it will look for a library with exactly that name.

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

回答by Code Krusty

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. 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.

l namespec --library=namespec 将 namespec 指定的存档或目标文件添加到要链接的文件列表中。此选项可以使用任意次数。如果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. 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.dll 的东西,直到我意识到我想要 ld 使用实际的文件名后才起作用。正如其他人发布的如何将库添加到链接器的截图一样,我需要做的就是将字段中的“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,

克鲁斯蒂,