使用相对路径构建的 boost 库 [英] boost libraries built with relative paths

查看:30
本文介绍了使用相对路径构建的 boost 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 QNX 6.5.0 中构建了 boost 1.57.0.没有构建错误.但是一些库链接到 libboost_system.so 指定相对路径.我保存了编译日志.这是 boost_thread 的链接步骤:

I built boost 1.57.0 in QNX 6.5.0. There is no build error. But some libraries are linked to libboost_system.so specifying relative path. I saved compilation logs. Here is linkage step for boost_thread:

"QCC_gpp"   -o "bin.v2/libs/thread/build/qcc/release/threading-multi/libboost_thread.so.1.57.0"  -shared "bin.v2/libs/thread/build/qcc/release/threading-multi/pthread/thread.o" "bin.v2/libs/thread/build/qcc/release/threading-multi/pthread/once.o" "bin.v2/libs/thread/build/qcc/release/threading-multi/future.o" "bin.v2/libs/system/build/qcc/release/threading-multi/libboost_system.so.1.57.0"    -lm 

所以,当我运行 ldd libboost_thread.so 时,它找不到 libboost_system.我认为 libboost_thread 应该与 -lboost_system 选项链接.但我不知道该怎么做.

So, When I run ldd libboost_thread.so, it can't find libboost_system. I think libboost_thread should be linked with -lboost_system option. But I don't know how to do this.

谢谢.

我无法构建任何与 boost_thread 链接的程序.因为,boost_thread 在 bin.v2/libs/system/build/qcc/release/threading-multi 文件夹中搜索 boost_system.但是 boost_thread 和 boost_system 都在库搜索文件夹中.(用LD_LIBRARY_PATH 定义)

I cannot build any program linking with boost_thread. Because, boost_thread searches boost_system in bin.v2/libs/system/build/qcc/release/threading-multi folder. However both boost_thread and boost_system are in a library search folder. (defined with LD_LIBRARY_PATH)

推荐答案

如果您运行 objdump -p libboost_thread.so,您会发现 libboost_system.so 的 NEEDED 条目包含一个(相对) 小路.根据 ELF 规范,NEEDED 条目应仅包含所需库的名称,因此链接器或 QCC 中似乎存在错误.

If you run objdump -p libboost_thread.so, you'll find that the NEEDED entry for libboost_system.so contains a (relative) path. According to the ELF specification, the NEEDED entry should contain only the name of the needed library, so there seems to be a bug in the linker or in QCC.

因为如果这样,系统将无法在运行时找到该文件,除非当前目录与链接发生时的目录相同.

Because if this, the system won't be able to find the file at run-time unless the current directory is the same as it was when linking took place.

最简单的解决方法是静态链接到 libboost_thread.a.

The simplest work-around is to link statically to libboost_thread.a.

我自己使用的另一种解决方法是围绕 QCC 创建一个包装器,用于转换命令行,以便将依赖项指定为 -Wl,-L ;-Wl,-l 而不是 /lib.so 这也需要对 Boost 构建系统进行更改,以便它不会附加库文件名末尾的版本号.

Another work-around that I've used myself is to create a wrapper around QCC that transforms the command line so that dependencies are given as -Wl,-L <path> -Wl,-l <name> instead of <path>/lib<name>.so This also requires a change to the Boost build system so that it doesn't append the version number to the end of library file names.

这篇关于使用相对路径构建的 boost 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆