Freeglut 程序编译但运行时显示错误:libglut.so.3: 无法打开共享对象文件
这是我的程序:
#include </usr/local/include/GL/glut.h>
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("Lighthouse3D- GLUT Tutorial");
}
编译:
g++ -lglut -L/usr/local/lib/ -o start 开始.cpp;./开始
显示错误:
./start:加载共享时出错 库:libglut.so.3:无法打开 共享对象文件:没有这样的文件或 目录
文件存在。
bash提示符>找到 libglut.so.3
/usr/local/lib/libglut.so.3
/usr/local/lib/libglut.so.3.9.0
也尝试过:
LD_RUN_PATH="/usr/local/lib/"
g++ -lglut -LLIBDIR -o start start.cpp;./start 没有运气。
这些是安装时显示的消息(如果有帮助的话):
root@Nav:/home/Nav/freeglut-2.6.0# make install 在 src 中安装
make[1]: 进入目录/home/Nav/freeglut-2.6.0/src'
/home/Nav/freeglut-2.6.0/src' 测试 -z“/usr/local/lib”|| /bin/mkdir -p "/usr/local/lib" /bin/sh ../libtool --mode=安装 /usr/bin/install -c 'libglut.la' '/usr/local/lib/libglut.la'
make[2]: 进入目录
/usr/bin/安装-c .libs/libglut.so.3.9.0 /usr/local/lib/libglut.so.3.9.0(cd /usr/local/lib && { ln -s -f libglut.so.3.9.0 libglut.so.3 || { rm -f libglut.so.3 && ln -s libglut.so.3.9.0 libglut.so.3; }; })
(cd /usr/local/lib && { ln -s -f libglut.so.3.9.0 libglut.so || { rm-f libglut.so && ln -s libglut.so.3.9.0 libglut.so; }; }) /usr/bin/安装 -c .libs/libglut.lai /usr/local/lib/libglut.la
/usr/bin/install -c .libs/libglut.a /usr/local/lib/libglut.a chmod 644 /usr/local/lib/libglut.a ranlib /usr/local/lib/libglut.a
PATH=“$PATH:/sbin” ldconfig -n /usr/local/lib
-------------------------------------------------- -------------------- 库已安装在:
/usr/local/lib 如果你曾经发生过 想要链接已安装的 给定目录中的库, LIBDIR,您必须使用 libtool, 并指定完整路径名 库,或使用-LLIBDIR' 标志 在链接期间并执行至少一项操作 以下:
-Wl,--rpath -Wl,LIBDIR'链接器标志
- 将 LIBDIR 添加到 LD_LIBRARY_PATH 环境变量中 执行期间
- 将 LIBDIR 添加到 LD_RUN_PATH 环境变量 链接期间
- 使用
- 让您的系统管理员将 LIBDIR 添加到 `/etc/ld.so.conf'
查看任何操作系统文档 关于共享库的更多信息 信息,例如 ld(1) 和 ld.so(8) 手册页。
This is my program:
#include </usr/local/include/GL/glut.h>
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("Lighthouse3D- GLUT Tutorial");
}
Compiled with:
g++ -lglut -L/usr/local/lib/ -o start
start.cpp;./start
Error shown:
./start: error while loading shared
libraries: libglut.so.3: cannot open
shared object file: No such file or
directory
The file is present.
bashprompt> locate libglut.so.3
/usr/local/lib/libglut.so.3
/usr/local/lib/libglut.so.3.9.0
Had also tried:
LD_RUN_PATH="/usr/local/lib/"
g++ -lglut -LLIBDIR -o start start.cpp;./start
with no luck.
These were the messages shown while installing (if this helps):
root@Nav:/home/Nav/freeglut-2.6.0#
make install Making install in src
make[1]: Entering directory/home/Nav/freeglut-2.6.0/src'
/home/Nav/freeglut-2.6.0/src' test
make[2]: Entering directory
-z "/usr/local/lib" || /bin/mkdir -p "/usr/local/lib" /bin/sh ../libtool
--mode=install /usr/bin/install -c 'libglut.la'
'/usr/local/lib/libglut.la'
/usr/bin/install -c
.libs/libglut.so.3.9.0
/usr/local/lib/libglut.so.3.9.0 (cd
/usr/local/lib && { ln -s -f
libglut.so.3.9.0 libglut.so.3 || { rm
-f libglut.so.3 && ln -s libglut.so.3.9.0 libglut.so.3; }; })
(cd /usr/local/lib && { ln -s -f
libglut.so.3.9.0 libglut.so || { rm -f
libglut.so && ln -s libglut.so.3.9.0
libglut.so; }; }) /usr/bin/install
-c .libs/libglut.lai /usr/local/lib/libglut.la
/usr/bin/install -c .libs/libglut.a
/usr/local/lib/libglut.a chmod 644
/usr/local/lib/libglut.a ranlib
/usr/local/lib/libglut.a
PATH="$PATH:/sbin" ldconfig -n
/usr/local/lib
---------------------------------------------------------------------- Libraries have been installed in:
/usr/local/lib If you ever happen
to want to link against installed
libraries in a given directory,
LIBDIR, you must either use libtool,
and specify the full pathname of the
library, or use the-LLIBDIR' flag
LD_LIBRARY_PATH' environment variable
during linking and do at least one of
the following:
- add LIBDIR to the
during execution
- add LIBDIR to theLD_RUN_PATH' environment variable
-Wl,--rpath -Wl,LIBDIR' linker flag
during linking
- use the
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation
about shared libraries for more
information, such as the ld(1) and
ld.so(8) manual pages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
LD_RUN_PATH
尝试非常接近,但它应该是LD_LIBRARY_PATH
:安装程序的这个提示也很方便:
如果你这样做了,你就不需要做
LD_LIBRARY_PATH
的事情了。Your
LD_RUN_PATH
attempt was very close, but it should beLD_LIBRARY_PATH
:This tip from the installer is also handy:
If you did that, you wouldn't need to do the
LD_LIBRARY_PATH
thing.