ld链接问题:/usr/bin/ld:找不到[库名] [英] ld linkage problems: /usr/bin/ld: cannot find [libraryname]

查看:287
本文介绍了ld链接问题:/usr/bin/ld:找不到[库名]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Qmake在Ubuntu 9.10上构建共享库

Im using Qmake to build a shared library on Ubuntu 9.10

此共享库(A)依赖于另一个共享库(B).

This shared library (A) has a dependency on another shared library (B).

项目B已成功构建.

在项目A的.pro文件中,我的LIBS变量如下所示:

in the .pro file for project A, my LIBS variable looks like this:

LIBS += -L../datelib/bin -llibdatelib_release.so.1.0.0

(我使用了完整的shlib名称,因为库的版本不同.)

(I used the full shlib name because the library versions are different.)

无论如何,当我尝试构建项目A时,它会在链接阶段中断,并显示错误消息:

In any case, when I attempt to build project A, it breaks at the linkage stage, and prints the error message:

/usr/bin/ld: cannot find -llibdatelib_release.so.1.0.0
collect2: ld returned 1 exit status
make[1]: ***[bin/libprojecta_release.so.6.0.0] Error 1
make ***[release] Error 2
Exited with code 2

从错误消息中,我以为ld抱怨无法找到libdatelib文件,因此我手动将其复制到/usr/lib/

From the error message, I thought ld was complaining that it could not locate the libdatelib file, so I manually copied it to /usr/lib/

但是,这并不能解决问题,并且我收到了相同的错误消息.

however, that did not solve the problem, and I am getting the same error message.

有人知道如何解决这个问题吗?

Anyone knows how to fix this?

我对使用gcc进行构建非常陌生.我知道如何创建符号链接,但是我要为lnk命令使用哪些路径?我要链接的文件位于/home/username/work/cppdev/datelib/bin.

I'm quite new to building using gcc. I know how to create symbolic links, but which paths do I use for the lnk command?. The file I want to link to is in /home/username/work/cppdev/datelib/bin.

我使用的构建系统(qmake)也会在构建过程中自动创建符号链接,因此我的/home/username/work/cppdev/datelib/bin文件夹中已经包含以下文件:

Also the build system I use (qmake), automatically creates symbolic links as part of the build, so I already have the following files in my /home/username/work/cppdev/datelib/bin folder:

  • libdatelib_release.so(符号链接)
  • libdatelib_release.so.1(符号链接)
  • libdatelib_release.so.1.0(符号链接)
  • libdatelib_release.so.1.0.0(共享库)

我可能不得不问另一个问题,以解释为什么有这么多的符号链接(是什么意思?),为什么我不能直接链接到共享库,而必须通过符号链接.我已经阅读了一些在线文档,但是到目前为止,我所看到的似乎更像是字典/传统,而不是实际的技术原因,为什么在Linux上进行链接时需要这种抽象级别.

I may have to ask another question to explain why there are so many symlinks (whats the point?), and why I cant just link directly to a shared lib, but have to go through a symbolic link. I've read some online docs, but what I've seen so far seems more like dictum/tradition rather than actual technical reasons WHY this level of abstraction is required when linking on Linux.

推荐答案

您不能那样使用-l. -l只能通过-lFOO查找具有libFOO.so之类名称的内容.如果要在构建中像这样指定它,则需要一个没有版本号的符号链接.

You can't use -l that way. -l can only find things with names like libFOO.so, via -lFOO. You need a symbolic link without the version number if you want to specify it like this in the build.

类似的东西:

ln -s /the/path/to/the/libthing.so.1.0.0 /the/path/to/the/libthing.so

现在-lthing就可以了.

Now -lthing will work.

这篇关于ld链接问题:/usr/bin/ld:找不到[库名]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆