如何判断 libboost_python.so 使用的是哪个 python 版本?
我想知道 python boost_python.so 需要什么版本。这是在一台具有多个 python 版本的计算机上,我自己没有构建/安装 boost(我也没有 root 访问权限)。
我如何知道 python boost_python.so 是为哪个版本编译的?
我在 ldd 的输出中没有找到任何有用的东西,但将其包含在此处以防其他人看到某些内容。
-bash-3.2$ ldd -v libboost_python.so.1.46.1
libutil.so.1 => /lib64/libutil.so.1 (0x00002ad65582d000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ad655a30000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002ad655c4b000)
librt.so.1 => /lib64/librt.so.1 (0x00002ad655e50000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00002ad656059000)
libm.so.6 => /lib64/libm.so.6 (0x00002ad656359000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002ad6565dd000)
libc.so.6 => /lib64/libc.so.6 (0x00002ad6567eb000)
/lib64/ld-linux-x86-64.so.2 (0x000000374c600000)
Version information:
./libboost_python.so.1.46.1:
libgcc_s.so.1 (GCC_3.0) => /lib64/libgcc_s.so.1
libpthread.so.0 (GLIBC_2.2.5) => /lib64/libpthread.so.0
libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
libstdc++.so.6 (CXXABI_1.3) => /usr/lib64/libstdc++.so.6
libstdc++.so.6 (GLIBCXX_3.4) => /usr/lib64/libstdc++.so.6
/lib64/libutil.so.1:
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libpthread.so.0:
ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_2.2.5) => /lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
libc.so.6 (GLIBC_2.3.2) => /lib64/libc.so.6
libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libdl.so.2:
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/librt.so.1:
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
libpthread.so.0 (GLIBC_2.2.5) => /lib64/libpthread.so.0
libpthread.so.0 (GLIBC_PRIVATE) => /lib64/libpthread.so.0
libc.so.6 (GLIBC_2.3.2) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
/usr/lib64/libstdc++.so.6:
ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
libgcc_s.so.1 (GCC_4.2.0) => /lib64/libgcc_s.so.1
libgcc_s.so.1 (GCC_3.3) => /lib64/libgcc_s.so.1
libgcc_s.so.1 (GCC_3.0) => /lib64/libgcc_s.so.1
libc.so.6 (GLIBC_2.3.2) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.3) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libm.so.6:
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libgcc_s.so.1:
libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libc.so.6:
ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
I'd like to know what version of python boost_python.so is expecting. This is on a computer with multiple python versions and I did not build/install boost myself (nor do i have root access).
How can i tell what version of python boost_python.so is compiled for?
I didn't find anything useful in the output from ldd but include it here incase someone else sees something.
-bash-3.2$ ldd -v libboost_python.so.1.46.1
libutil.so.1 => /lib64/libutil.so.1 (0x00002ad65582d000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ad655a30000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002ad655c4b000)
librt.so.1 => /lib64/librt.so.1 (0x00002ad655e50000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00002ad656059000)
libm.so.6 => /lib64/libm.so.6 (0x00002ad656359000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002ad6565dd000)
libc.so.6 => /lib64/libc.so.6 (0x00002ad6567eb000)
/lib64/ld-linux-x86-64.so.2 (0x000000374c600000)
Version information:
./libboost_python.so.1.46.1:
libgcc_s.so.1 (GCC_3.0) => /lib64/libgcc_s.so.1
libpthread.so.0 (GLIBC_2.2.5) => /lib64/libpthread.so.0
libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
libstdc++.so.6 (CXXABI_1.3) => /usr/lib64/libstdc++.so.6
libstdc++.so.6 (GLIBCXX_3.4) => /usr/lib64/libstdc++.so.6
/lib64/libutil.so.1:
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libpthread.so.0:
ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_2.2.5) => /lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
libc.so.6 (GLIBC_2.3.2) => /lib64/libc.so.6
libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libdl.so.2:
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/librt.so.1:
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
libpthread.so.0 (GLIBC_2.2.5) => /lib64/libpthread.so.0
libpthread.so.0 (GLIBC_PRIVATE) => /lib64/libpthread.so.0
libc.so.6 (GLIBC_2.3.2) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
/usr/lib64/libstdc++.so.6:
ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
libgcc_s.so.1 (GCC_4.2.0) => /lib64/libgcc_s.so.1
libgcc_s.so.1 (GCC_3.3) => /lib64/libgcc_s.so.1
libgcc_s.so.1 (GCC_3.0) => /lib64/libgcc_s.so.1
libc.so.6 (GLIBC_2.3.2) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.3) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libm.so.6:
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libgcc_s.so.1:
libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
/lib64/libc.so.6:
ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是您要找的吗?
以上适用于基于 Debian 的发行版。我相信 Fedora 的对应词应该是:
HTH!
Is this what you are looking for?
The above works for debian-based distros. I believe the equivalent for Fedora should be:
HTH!
来自:https://github.com/mapnik/mapnik/wiki/InstallationTroubleshooting
“并且有时甚至这不起作用。提示:传递 -d2 标志来查看 bjam 发送到 gcc 的所有编译命令,您可能会在编译参数中看到类似 -I/usr/include/python24 的内容。 -I/usr/include/python26 (或某些旧版本的 python 标头)。如果发生这种情况,您可以制作一个完整的配置文件(包含所有可能的 python 信息)并在 bjam 命令行上传递对该文件的引用。这是在这里: http://www.boost.org/doc/libs/1_42_0/libs/python/doc/building.html#configuring-boost-build,示例如下:
创建文件名为“user-config.jam”(但更改 python 版本以使其合适):
“
查找 .jam 配置文件。如果存在,请检查“using python”命令。如果不存在,请针对 bjam 运行 -d2 标志以确定它使用的 python 的默认位置。这显然不是一种直接方法,只会根据输入给您留下一个可能的答案(但也许这已经足够好了)。
From: https://github.com/mapnik/mapnik/wiki/InstallationTroubleshooting
"And sometimes even that does not work. HINT: pass the -d2 flag to see all the compile commands sent to gcc by bjam and you will likely see something like -I/usr/include/python24 in the compile arguments when it should be -I/usr/include/python26 (or some older version of python headers). If this happens then you can craft a full config file (with all possible python info) and pass a reference to that on the bjam command line. Docs on this are here: http://www.boost.org/doc/libs/1_42_0/libs/python/doc/building.html#configuring-boost-build, and an example follows:
Create a file called 'user-config.jam' (but change the python versions to be appropriate):
"
Look for a .jam config file. If it exists check for the 'using python' command. If it doesn't exist, run the -d2 flag against bjam to determine the default location of python that it uses. This obviously isn't a direct method and would simply leave you with a likely answer given the inputs (but maybe that's good enough).
我意识到 OP 询问如何在 Linux 环境中执行此操作,但我在 Windows 环境中也遇到了同样的问题,并认为在这里分享的信息可能会有所帮助。
要查看将自动链接到生成的可执行文件中的 Python DLL,请使用 Visual Studio 附带的
dumpbin
实用程序。只需打开 Visual Studio 开发人员命令提示符,然后运行:这至少会告诉您构建 Boost 时使用的 Python 主要/次要版本。例如,如果您在构建 Boost 时使用 Python 3.5.2,则此命令将返回一堆带有文本的行:
I realize the OP was asking about how to do this in a Linux environment, but I had the same question in a Windows environment, and thought it may be helpful information to share here.
To see the Python DLL that will be auto-linked into the resulting executable, use the
dumpbin
utility that comes with Visual Studio. Simply open a Visual Studio developer command prompt, and run:That will at least tell you the major/minor version of Python that was used when building Boost. For example, if you used Python 3.5.2 when building Boost, this command would return a bunch of lines with the text:
有趣的是,在我的 OS X 系统上,otool -L 确实列出了 python 库,但在 Linux 系统上我可以访问它,它似乎被保留为未满足的依赖项,并且未在ldd 输出。
就我而言,我知道它是针对 python 2.7 编译的,但是对
strings /.../libboost_python.so
的输出进行检查后发现没有提及2.7
,并且27
仅出现在与 python 版本无关的损坏符号中。所以我的结论是,如果不寻找 2.6 和 2.7 版本之间符号的 API 差异,就不可能判断。
也许检查修改后的时间戳会缩小范围?
Interestingly, on my OS X system,
otool -L
does list the python library, but on the linux system I have access to it seems to be left as an unmet dependency, and isn't listed in theldd
output.In my case, I know it was compiled against python 2.7, but a check of the output of
strings /.../libboost_python.so
reveals no mention of2.7
, and27
only occurs in mangled symbols unrelated to the python version.So I conclude that it isn't possible to tell, without looking for API differences in symbols between, say, 2.6, 2.7 versions.
Perhaps checking the modified timestamp would narrow it down?