gcc 找不到要链接的库
我正在使用 Ubuntu,我的 IDE 是 Aptana 3.0
我在尝试构建时收到以下错误。库 libfcgi.a
位于 /usr/local/lib/
中。
在项目属性的 Library C++ Linker 部分中,我将 /usr/local/lib/
添加到搜索路径和文件 /usr/local/lib/libfcgi.a
>。
为什么我还是无法构建?
**** Build of configuration Debug for project rtb ****
make all
Building target: rtb
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o"rtb" ./src/rtb.o -l/usr/local/lib/libfcgi.a
/usr/bin/ld: cannot find -l/usr/local/lib/libfcgi.a
collect2: ld returned 1 exit status
make: *** [rtb] Error 1
I am using Ubuntu and my IDE is Aptana 3.0
I am getting the following error when trying to build. The library libfcgi.a
is located in /usr/local/lib/
.
In the Library C++ Linker section of the project properties, I added /usr/local/lib/
to the search path and the file /usr/local/lib/libfcgi.a
.
Why can I still not build?
**** Build of configuration Debug for project rtb ****
make all
Building target: rtb
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o"rtb" ./src/rtb.o -l/usr/local/lib/libfcgi.a
/usr/bin/ld: cannot find -l/usr/local/lib/libfcgi.a
collect2: ld returned 1 exit status
make: *** [rtb] Error 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想这可能就是你想要的;
-l<值>将自动在用 -L 列出的所有文件夹中查找名为 lib.a 或 lib.so 的库,您只需要“-lfcgi”即可。
I think this may be what you want;
-l<value> will automatically look in all folders listed with -L for a library named lib<value>.a or lib<value>.so, all you need is the '-lfcgi'.
尝试使用“-lfcgi”代替
Try "-lfcgi" instead
您的链接器标志是错误的,它需要是
-lfcgi
而不是带有“lib”前缀和 .a 后缀的整个路径。您可以手动更改它,也可以在 Apatana 中更改。为此,您不必两次向他提供您的库的完整合格路径。 (你已经给了他搜索路径,还记得吗?)。通常你会像这样定义额外的库:
cfgi
并且您的 IDE 会完成剩下的工作,将其添加到链接器标志中!Your linker flag is wrong it needs to be
-lfcgi
and not the whole path with the "lib" prefix and the .a suffix.You can change it by hand, or in Apatana. To do so you don't have to give him the full qualified path to your lib two times. ( You already gave him the search path, remember? ). Usually you define additional libraries just like this:
cfgi
and your IDE does the rest to add it to the linker flags!您应该这样做
在不太可能的情况下,
/usr/local/lib/
不在您的搜索路径中,您可以在命令行中添加该路径,例如或将其放入在调用编译命令之前在环境变量
LIBRARY_PATH
中,例如使用 bash:如果您坚持给出显式文件名,请省略
-l
:但是我建议不要因为它不灵活。如果问题是安装了另一个不兼容版本的库,最好确保正确的版本位于搜索路径中的第一个(或者更好的是,确保错误的版本根本不在搜索路径中) ― 甚至可以将其从系统中删除)。
You should do
In the unlikely case that
/usr/local/lib/
is not in your search path, you can either add that path in the command line likeor put it in the environment variable
LIBRARY_PATH
before calling your compile command, e.g. with bash:If you insist in giving the explicit file name, omit the
-l
:However I'd advise against that because it's inflexible. If the issue is that there's another, incompatible version of the library installed, it's better to make sure that the correct one comes first in the search path (or even better, make sure that the wrong one isn't in the search path at all ― maybe even by removing it from the system).
这是为了帮助大家……非常感谢。
这是解决方案。我必须使用 -lfcgi++ 并添加了
g++ -L/usr/local/include/ -lfcgi++ -o"rtb" ./src/rtb.o
以上是 aptanta 控制台的输出。我尝试了 -lfcgi 但没有成功。谷歌搜索导致使用-lfcgi++。
That's for the help all....really appreciate it.
Here is the solution. I had to use -lfcgi++ and I added the
g++ -L/usr/local/include/ -lfcgi++ -o"rtb" ./src/rtb.o
The above was the output from aptanta console. I tried -lfcgi and did not work. Google search lead to using -lfcgi++.