为什么 GNU 链接器找不到带有 -l的共享对象?
我在尝试链接目标文件时遇到错误:
$ g++ -o intro intro.o -L -Wl,-rpath-link -lnotes -lm -lnsl -lpthread -lc -lresolv -ldl
/usr/bin/ld: cannot find -lnotes
collect2: ld returned 1 exit status
但是,该库似乎在那里(事实上,我通过在文件中包含 /opt/ibm/lotus/notes
将其放在那里在 /etc/ld.so.conf.d/
中并运行 ldconfig
):
$ ldconfig --print-cache | grep libnotes
361: libnoteswc.so (libc6) => /opt/ibm/lotus/notes/libnoteswc.so
362: libnotes.so (libc6) => /opt/ibm/lotus/notes/libnotes.so
为什么链接失败以及如何使链接器使用这些共享对象?
I'm getting an error when trying to link an object file:
$ g++ -o intro intro.o -L -Wl,-rpath-link -lnotes -lm -lnsl -lpthread -lc -lresolv -ldl
/usr/bin/ld: cannot find -lnotes
collect2: ld returned 1 exit status
However, the library seems to be there (in fact, I put it there by including /opt/ibm/lotus/notes
in a file in /etc/ld.so.conf.d/
and running ldconfig
):
$ ldconfig --print-cache | grep libnotes
361: libnoteswc.so (libc6) => /opt/ibm/lotus/notes/libnoteswc.so
362: libnotes.so (libc6) => /opt/ibm/lotus/notes/libnotes.so
Why does the linking fail and how can I bring the linker to use these shared objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://gcc.gnu.org/faq.html#rpath
http://gcc.gnu.org/faq.html#rpath
尝试使用 ld 的 -L 标志。我的 Makefile 之一的示例:
我认为“/etc/ld.so.conf.d/”中描述的库仅适用于运行时......希望这有帮助!
Try with the -L flag for ld. An example of one of my Makefile :
I think libraries described in "/etc/ld.so.conf.d/" are for runtime only ... Hope this helps !