glui /usr/bin/ld: 找不到 -lXmu

发布于 2024-08-31 10:44:48 字数 717 浏览 8 评论 0原文

我已经下载了最新的 GLUI 源代码,现在我正在尝试编译它。当我这样做时,我收到以下错误:

g++ -O0 -Wall -pedantic -I./ -I./include -I/usr/X11R6/include -o bin/example1 example/example1.cpp  -L./lib -lglui -L/usr/X11R6/lib/libXdmcp.a -lglut -lGLU -lGL -lXmu -lXext -lX11 -lXi -lm
/usr/bin/ld: cannot find -lXmu
collect2: ld returned 1 exit status

当我执行locate libXmu时,我收到以下输出:

> %:~/src/GLUI/src$ locate libXmu 
> /usr/lib/libXmu.so.6
> /usr/lib/libXmu.so.6.2.0
> /usr/lib/libXmuu.so.1
> /usr/lib/libXmuu.so.1.0.0

我收到错误是因为我没有 /usr/lib/libXmu.lib 吗?所以?如果是这种情况,我该如何制作呢? (我根本没有链接经验)。

谢谢!

I have downloaded the latest GLUI source code and now I am trying to compile it. When I do so, I get the following error:

g++ -O0 -Wall -pedantic -I./ -I./include -I/usr/X11R6/include -o bin/example1 example/example1.cpp  -L./lib -lglui -L/usr/X11R6/lib/libXdmcp.a -lglut -lGLU -lGL -lXmu -lXext -lX11 -lXi -lm
/usr/bin/ld: cannot find -lXmu
collect2: ld returned 1 exit status

When I did a locate libXmu, I get the following output:

> %:~/src/GLUI/src$ locate libXmu 
> /usr/lib/libXmu.so.6
> /usr/lib/libXmu.so.6.2.0
> /usr/lib/libXmuu.so.1
> /usr/lib/libXmuu.so.1.0.0

Do I get the error because I don't have a /usr/lib/libXmu.so? If this is the case, how can I make one? (I am not experienced with linking at all).

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

简单爱 2024-09-07 10:44:48

Linux 发行版通常将运行程序所需的库与构建程序所需的文件分开打包。

查找名为 *-devel 或 *-dev 的包。

我不知道您特别需要哪一个,但您可以使用 apt-cache search 来查找它。

Linux distributions usually package the libraries needed for running programs separately from the files needed to build programs.

Look for packages named *-devel or *-dev.

I don't know which one you need in particular for this, but you can use apt-cache search to look for it.

病女 2024-09-07 10:44:48

答案实际上是最初的答案之一,但似乎被所有者删除了。我能够通过创建到最新版本的库的符号链接(即/usr/lib/libXmu.so.6)并成功编译代码来解决该问题。

The answer was actually one of the first ones here originally but the owner deleted it, it seems. I was able to solve the problem by creating a symbolic link to the latest version of the library (i.e. /usr/lib/libXmu.so.6) and compile the code successfully.

南冥有猫 2024-09-07 10:44:48

我遇到了同样的问题,如果创建符号链接没有帮助,
尝试以下操作:

  1. 打印您的 $PATH ("echo $PATH"),
    并检查您需要的库文件是否位于这些目录之一中。
    使用“export PATH=/newly/added/path:$PATH”添加新目录进行检查。
  2. 我已经包含了libevent,在gcc命令中添加了“-levent”,并且ld使用了文件/usr/lib/libevent.so,所以看起来“lib”前缀和扩展名是由ld自动添加的。

继续努力吧。

I had the same problem, if creating a symbolic link doesnt help,
try the following:

  1. Print your $PATH ("echo $PATH"),
    and check if the library file you need is in one of those directories.
    Use "export PATH=/newly/added/path:$PATH" to add new directory to check.
  2. Ive been including libevent, added "-levent" in the gcc command, and ld used file /usr/lib/libevent.so, so it looks like the "lib" prefix and extension are being added automatically by ld.

Keep it up.

横笛休吹塞上声 2024-09-07 10:44:48

从 Ubuntu 22.04 开始(也可能在早期版本中),包 libxmu6 提供以下文件(其中一个是符号链接):

/usr/lib/x86_64-linux-gnu/libXmu.so.6
/usr/lib/x86_64-linux-gnu/libXmu.so.6.2.0

而包 libxmu-dev 提供以下文件(实际上是一个符号链接):

/usr/lib/x86_64-linux-gnu/libXmu.so

libXmu.so 符号链接是链接器将找到的内容(如果存在)。

因此,要通过 apt 安装 libXmu.so 符号链接,请运行以下命令(如@Salami 上面所述):

sudo apt-get install libxmu-dev libxmu-headers

As of Ubuntu 22.04 (and probably also in earlier versions), the package libxmu6 provides the following files (one of which is a symlink):

/usr/lib/x86_64-linux-gnu/libXmu.so.6
/usr/lib/x86_64-linux-gnu/libXmu.so.6.2.0

Whereas the package libxmu-dev provides the following file (which is actually a symlink):

/usr/lib/x86_64-linux-gnu/libXmu.so

The libXmu.so symlink is what the linker will find, if it exists.

So to install the libXmu.so symlink via apt, run the below command (as mentioned by above by @Salami):

sudo apt-get install libxmu-dev libxmu-headers
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文