哪个链接器设置决定共享库的加载路径?
我在 Mac 上构建了 Poco C++ 库。检查构建的输出文件时,我注意到它们的加载路径是指向构建目录的绝对路径。例如:
$ otool -L libPocoFoundation.dylib
libPocoFoundation.dylib:
/Users/francis/orig/poco-1.3.6p2/lib/Darwin/i386/libPocoFoundation.9.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
哪个编译器或链接器选项决定了这一点?我怎样才能覆盖这个? (在编译时。我知道之后可以使用install_name_tool
更改它。)
编辑
编译器是g++-4.0
(gcc版本4.0.1 Apple)。
链接器是 libtool
(Apple Computer, Inc. 版本 cctools-782)
我当前正在仔细阅读 makefile。也许我会自己解决。但欢迎所有帮助!
I have built the Poco C++ library on Mac. When inspecting the built output files I notice that their load paths are absolute paths that point to the build directory. For example:
$ otool -L libPocoFoundation.dylib
libPocoFoundation.dylib:
/Users/francis/orig/poco-1.3.6p2/lib/Darwin/i386/libPocoFoundation.9.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
Which compiler or linker option determined this? How can I override this? (At compile time. I know that I can change it afterwards with the install_name_tool
.)
Edit
The compiler is g++-4.0
(gcc version 4.0.1 Apple).
The linker is libtool
(Apple Computer, Inc. version cctools-782)
I'm perusing the makefiles currently. Perhaps I'll figure it out myself. But all help is welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
stackoverflow.com 上的相关问题 “如何在 Mac OSX 下使用 gcc 设置可执行文件的运行时路径 (-rpath)?” 解释了在编译时执行此操作的一些方法。
顺便说一句:我在 MacOS Leopard 上重现了您的 POCO 错误,并打开了 错误 3164792
Related question at stackoverflow.com "How to set the runtime path (-rpath) of an executable with gcc under Mac OSX?" explains some ways to do it at compile-time.
BTW: I've reproduced your POCO bug on MacOS Leopard and opened a bug 3164792 for POCO-1.4.0