无法找到-lGL,没有符号链接怎么办?
我正在编译一个共享库,在 ld 命令上使用 -lGL
。但它在我的系统上找不到 libGL.so。 Nvidia 软件包在 /etc/ld.so.conf.d/
中正确设置库路径。 甚至是 ldconfig -p | 的输出grep libGL.so 找到了它:
libGL.so.1 (libc6,x86-64) => /usr/lib/nvidia-current/libGL.so.1
libGL.so.1 (libc6) => /usr/lib32/nvidia-current/libGL.so.1
libGL.so (libc6,x86-64, OS ABI: Linux 2.4.20) => /usr/lib/x86_64-linux-gnu/libGL.so
libGL.so (libc6,x86-64) => /usr/lib/nvidia-current/libGL.so
libGL.so (libc6, OS ABI: Linux 2.4.20) => /usr/lib32/libGL.so
libGL.so (libc6) => /usr/lib32/nvidia-current/libGL.so
我几乎在所有地方都读到了能够与其链接的信息,我基本上有 2 个解决方案:
将 nvidia libGL.so 链接到标准 /usr/lib 位置。对于任何尝试编译 opengl 库的人来说,这似乎都是错误的。为什么链接器不使用 ldconfig 缓存?
手动将 -L/usr/lib/nvidia-current 附加到库搜索路径。再次,错误的是,我如何知道在所有系统上可以找到该库的每个路径?
所以我真正的问题是:与不在标准位置但位置已在 /etc/ld.so.conf
注册的库链接的标准和自动方法是什么?
I'm compiling a shared library, with a -lGL
on the ld command. But it can't find the libGL.so on my system. Nvidia package correctly set libraries path in /etc/ld.so.conf.d/
.
Even the output of ldconfig -p | grep libGL.so
found it:
libGL.so.1 (libc6,x86-64) => /usr/lib/nvidia-current/libGL.so.1
libGL.so.1 (libc6) => /usr/lib32/nvidia-current/libGL.so.1
libGL.so (libc6,x86-64, OS ABI: Linux 2.4.20) => /usr/lib/x86_64-linux-gnu/libGL.so
libGL.so (libc6,x86-64) => /usr/lib/nvidia-current/libGL.so
libGL.so (libc6, OS ABI: Linux 2.4.20) => /usr/lib32/libGL.so
libGL.so (libc6) => /usr/lib32/nvidia-current/libGL.so
I read almost everywhere that to be able to link with it, i have basically 2 solutions:
Link the nvidia libGL.so to a standard /usr/lib location. That seem wrong for anybody what will try to compile an opengl library. Why the linker is not using the ldconfig cache ?
Append manually the -L/usr/lib/nvidia-current to the library search path. Again, wrong, how can i know every path where the library could be found on all the system ?
So my real question is: What is the standard and automatic approach for linking with a library not in a standard location, but location already register with /etc/ld.so.conf
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/etc/ld.so.conf
由/lib/ld.so
用于在运行时解析共享库,它与编译时链接内容无关。正确的方法是链接到
/usr/lib/x86_64-linux-gnu/
中的libGL.so
,应用程序将使用 nvidia 的libGL.so 在运行时。这应该不是问题,因为 OpenGL 接口是稳定的,并且两个库中的符号是相同的,只是实现不同。
/etc/ld.so.conf
is used by/lib/ld.so
to resolve shared libraries at runtime, it has nothing to do with linking stuff at compile time.What is the right way to do is just linking to
libGL.so
in/usr/lib/x86_64-linux-gnu/
and the application will use the nvidia'slibGL.so
on runtime. This shouldn't be a problem because the OpenGL interface is stable and symbols are the same in both libraries, its the implementation that is different.