c++ - python 扩展的静态链接 glibc & boost_python36
问题描述
我正在为 pyton3.6 编写扩展。我的开发机运行gcc7.3,生产环境os是centos6。我使用以下链接选项静态链接 glibc 以避免将 glibc2.12 升级到 glibc2.14+。
-Wl,-Bdynamic -lpython3.6m -Wl,-Bstatic -lboost_python36
但得到错误:
[ 50%] Linking CXX shared module helloext.so
/usr/bin/x86_64-linux-gnu-ld: cannot find -lgcc_s
/usr/bin/x86_64-linux-gnu-ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
CMakeFiles/helloext.dir/build.make:94: recipe for target 'helloext.so' failed
make[2]: *** [helloext.so] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/helloext.dir/all' failed
make[1]: *** [CMakeFiles/helloext.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
有人知道吗?谢谢。
解决方案
原因可能是尽管存在 libgcc,但它可能不在ldconfig已知的路径中。通过做检查这个
/sbin/ldconfig -p | grep libgcc
输出是否显示有一个指向 libgcc 的链接对应于您上面列出的路径?
一种解决方法可能是将相关库的链接添加到您的编译命令中,例如
... -L /usr/lib/gcc/x86_64-linux-gnu/4.6/
另一个可能是自己创建一个到库的符号链接。
ln -s /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so /usr/lib/gcc/libgcc_s.so
您尚未告知我们您正在使用的 Linux。在上面的命令中使用正确的数字更新 4.6。
推荐阅读
- java - 在 AWS linux 上安装 java Open JDK 10
- c# - 以编程方式创建的 CheckBox 不会触发 Checked/Unchecked 事件
- android - 棉花糖上没有火力通知的声音,但适用于奥利奥
- java - 在 JTable 中如何遍历 TableCellEditor 焦点的焦点以及单元格焦点
- spring - 无法正确测试 ErrorController Spring Boot
- encryption - Control-M GPG:mdc_packet 编码无效,解密失败
- javascript - 如何使用 .animate 更改文本颜色
- office365 - Microsoft 图形 API 组别名
- python - 在 Jupyter 上启动 python 脚本作为后台作业
- clickhouse - NOT IN 子查询速度慢并且内存不足(Clickhouse)