使用 gcc 链接到库时出现问题

发布于 2024-09-16 07:50:55 字数 918 浏览 14 评论 0原文

我今天从头开始安装了 SFML,这样我就可以开发游戏了。我下载了源代码,运行 sudo make install,尝试编译我的一个旧项目,但无法正确链接。因此,我尝试运行一个更简单的项目:教程中的示例之一。我尝试专门编译 这个 ,但我得到了这些错误:

g++ -o atest test.cpp -lsfml-graphics -lsfml-window -lsfml-system /tmp/ccaa86fR.o: In function `main':
test.cpp:(.text+0x1d2): undefined reference to `gluPerspective'
collect2: ld returned 1 exit status
make: *** [test] Error 1

尝试一个更简单的项目,初始教程,我在编译时没有遇到问题。但是,当我尝试运行它时,出现此错误:

./atest: error while loading shared libraries: libsfml-graphics.so.1.6: cannot open shared object file: No such file or directory

我检查过,文件确实安装到了 /usr/local/lib/ ,据我所知,这是它们应该去的地方。我在这里做错了什么?

I installed SFML from scratch today so I could work on a game. I downloaded the source, ran sudo make install, tried compiling one of my old projects, and I couldn't get it to link properly. So I tried running a simpler project: one of the samples in the tutorials. I tried to compile this one specifically, but I get these errors:

g++ -o atest test.cpp -lsfml-graphics -lsfml-window -lsfml-system /tmp/ccaa86fR.o: In function `main':
test.cpp:(.text+0x1d2): undefined reference to `gluPerspective'
collect2: ld returned 1 exit status
make: *** [test] Error 1

Trying an even simpler project, the one in the initial tutorial, I don't run into problems compiling. However, when I try to run it, I get this error:

./atest: error while loading shared libraries: libsfml-graphics.so.1.6: cannot open shared object file: No such file or directory

I checked, and the files did install to /usr/local/lib/ which is where they're supposed to go as far as I know. What am I doing wrong here?

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

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

发布评论

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

评论(1

情话墙 2024-09-23 07:50:55

-lGLU 应该修复第一个错误,对于第二个错误,请确保 /usr/local/lib/ 位于您的 ldconfig 搜索路径中 (/etc/ld. so.conf/etc/ld.so.conf.d/* 在 Ubuntu 下),并且您运行了 ldconfig: sudo ldconfig -v 然后尝试运行再次。

另请参阅man ldconfig

-lGLU should fix the first error and for the second one make sure /usr/local/lib/ is in your ldconfig search path (/etc/ld.so.conf and /etc/ld.so.conf.d/* under Ubuntu) and that you ran ldconfig: sudo ldconfig -v then try running again.

see also man ldconfig

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