免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6319 | 回复: 8
打印 上一主题 下一主题

[Problem here] Linux, 编译, Python, Hashlib, Openssl [复制链接]

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-07-29 21:28 |只看该作者 |倒序浏览
环境:Linux, 64bit, python2.7.3/python3.2.3, openssl1.0.1/openssl9.7.0
编译:
1, openssl :
   ./config --prefix=/home/liangdong/libs
   make -t
   make depend
2, python:
   ./configure --prefix=/home/liangdong/libs
    make & make install
分析:
从make打印的gcc command来看, 的确是指定了正确的Library路径, 可以找到libssl.so和libcrypto.so, 但我没看懂:
renaming "_hashlib" since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory

这是想要表达什么意思, 无论如何, 我尝试了各种尝试, 谷歌了各种百度, 百度了各种谷歌, 最终未能resolve.

Python与openssl版本分别尝试过两个, 总共2 * 2 = 4种搭配方式, 未能成功, 错误相同, 希望找到遇过同样错误的有缘人.

编译时,
_posixsubprocess也报错, 我进去改了一下源码就好了, 但这个ssl找不到的问题我就很费解了, 应该是libssl.so 软链的 libssl.so.1.0.1 找不到, 这尼玛有找不到的理由吗? 不懂.

24小时围观此贴, 坐等好人.
  1. [liangdong@bb-browser-test00.vm.baidu.com Python-2.7.3]$ make
  2. -----------------------------------------------
  3. Modules/Setup.dist is newer than Modules/Setup;
  4. check to make sure you have all the updates you
  5. need in your Modules/Setup file.
  6. Usually, copying Modules/Setup.dist to Modules/Setup will work.
  7. -----------------------------------------------
  8. running build
  9. running build_ext
  10. building dbm using gdbm
  11. INFO: Can't locate Tcl/Tk libs and/or headers
  12. building '_ssl' extension
  13. gcc -pthread -fPIC -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/home/liangdong/libs/include -I. -IInclude -I./Include -I/usr/local/include -I/home/liangdong/tars/Python-2.7.3/Include -I/home/liangdong/tars/Python-2.7.3 -c /home/liangdong/tars/Python-2.7.3/Modules/_ssl.c -o build/temp.linux-x86_64-2.7/home/liangdong/tars/Python-2.7.3/Modules/_ssl.o
  14. gcc -pthread -shared -L/home/liangdong/libs -L/home/liangdong/libs build/temp.linux-x86_64-2.7/home/liangdong/tars/Python-2.7.3/Modules/_ssl.o -L/home/liangdong/libs/lib -L/home/liangdong/libs -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.7/_ssl.so
  15. *** WARNING: renaming "_ssl" since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory
  16. building '_hashlib' extension
  17. gcc -pthread -fPIC -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/home/liangdong/libs/include -I. -IInclude -I./Include -I/usr/local/include -I/home/liangdong/tars/Python-2.7.3/Include -I/home/liangdong/tars/Python-2.7.3 -c /home/liangdong/tars/Python-2.7.3/Modules/_hashopenssl.c -o build/temp.linux-x86_64-2.7/home/liangdong/tars/Python-2.7.3/Modules/_hashopenssl.o
  18. gcc -pthread -shared -L/home/liangdong/libs -L/home/liangdong/libs build/temp.linux-x86_64-2.7/home/liangdong/tars/Python-2.7.3/Modules/_hashopenssl.o -L/home/liangdong/libs/lib -L/home/liangdong/libs -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.7/_hashlib.so
  19. *** WARNING: renaming "_hashlib" since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory

  20. Python build finished, but the necessary bits to build these modules were not found:
  21. _tkinter           bsddb185           dl              
  22. imageop            sunaudiodev                        
  23. To find the necessary bits, look in setup.py in detect_modules() for the module's name.


  24. Failed to build these modules:
  25. _hashlib           _ssl                              

  26. running build_scripts
复制代码

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
2 [报告]
发表于 2012-07-29 21:40 |只看该作者
自己解决:

          网上可以搜索到一个靠谱的答案, 虽然发生了一些变化, 但最终还是报错找不到libssl.so.1.0.1, 方法与编译结果如下:

1, 编辑Modules/Setup:
  1. 209 # Socket module helper for socket(2)
  2. 210 _socket socketmodule.c
  3. 211
  4. 212 # Socket module helper for SSL support; you must comment out the other
  5. 213 # socket line above, and possibly edit the SSL variable:
  6. 214 SSL=/home/liangdong/libs
  7. 215 _ssl _ssl.c \
  8. 216     -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
  9. 217     -L$(SSL)/lib -lssl -lcrypto
复制代码
2, make, 报错:
  1. gcc -pthread -L/home/liangdong/libs -Xlinker -export-dynamic -o python \
  2.                 Modules/python.o \
  3.                 libpython2.7.a -lpthread -ldl  -lutil -L/home/liangdong/libs/lib -lssl -lcrypto   -lm  
  4. libpython2.7.a(posixmodule.o)(.text+0x4801): In function `posix_tmpnam':
  5. ./Modules/posixmodule.c:7432: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
  6. libpython2.7.a(posixmodule.o)(.text+0x46e7): In function `posix_tempnam':
  7. ./Modules/posixmodule.c:7379: warning: the use of `tempnam' is dangerous, better use `mkstemp'
  8. ./python: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
  9. make: *** [sharedmods] Error 127
复制代码
发现是运行python加载动态库报错, 于是export LD_LILBRARY_PATH=/home/liangdong/libs/lib搞定.

是上天在磨砺我坚强的品质吗?...

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
3 [报告]
发表于 2012-07-29 21:44 |只看该作者
我只能说这个解决方案太烂了.... 我没权限改ld.so.conf, 只能加在自己的.bashrc里, 太不完美了.

有没有人遇见并修正过这个问题的.

论坛徽章:
2
CU大牛徽章
日期:2013-04-17 11:46:28CU大牛徽章
日期:2013-04-17 11:46:39
4 [报告]
发表于 2012-07-29 21:50 |只看该作者
貌似主要问题还是 configure 时没有找到相关的库

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
5 [报告]
发表于 2012-07-29 22:02 |只看该作者
Python太没爱了, 这不是伤害我的心吗.

论坛徽章:
0
6 [报告]
发表于 2012-07-29 22:09 |只看该作者
回复 1# linux_c_py_php
软连接 libssl.so.1.0.0存在吗?ln -s /home/liangdong/libs/libssl.so    /home/liangdong/libs/libssl.so.1.0.0行不行?

   

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
7 [报告]
发表于 2012-07-29 22:31 |只看该作者
存在的..

应该是python的脚本没处理好Modules, 安装在非标准路径下的有问题.

我直接依赖公司/usr/lib64下的ssl就可以了, 不考虑这个问题了.

编译Mod_python又是一堆错, 估计apache 2.4.2 版本太高了, 改够了.

论坛徽章:
26
CU大牛徽章
日期:2013-03-13 15:15:08水瓶座
日期:2014-08-31 19:44:01卯兔
日期:2014-09-05 08:48:33摩羯座
日期:2014-09-07 13:03:35子鼠
日期:2014-09-10 08:42:36白羊座
日期:2014-09-20 12:39:07丑牛
日期:2014-09-24 07:35:252015年亚洲杯之阿联酋
日期:2015-02-03 17:42:542015年亚洲杯之卡塔尔
日期:2015-02-11 13:13:022015年亚洲杯之约旦
日期:2015-03-03 15:10:522015年辞旧岁徽章
日期:2015-03-03 16:54:152015年亚洲杯之卡塔尔
日期:2015-03-27 14:08:09
8 [报告]
发表于 2012-08-01 15:04 |只看该作者
你是怎么解决_posixsubprocess报错的?我在源代码文件里面找不到这个模块,就试着去找这个模块的补丁。没找着。就更别谈改代码了

论坛徽章:
26
CU大牛徽章
日期:2013-03-13 15:15:08水瓶座
日期:2014-08-31 19:44:01卯兔
日期:2014-09-05 08:48:33摩羯座
日期:2014-09-07 13:03:35子鼠
日期:2014-09-10 08:42:36白羊座
日期:2014-09-20 12:39:07丑牛
日期:2014-09-24 07:35:252015年亚洲杯之阿联酋
日期:2015-02-03 17:42:542015年亚洲杯之卡塔尔
日期:2015-02-11 13:13:022015年亚洲杯之约旦
日期:2015-03-03 15:10:522015年辞旧岁徽章
日期:2015-03-03 16:54:152015年亚洲杯之卡塔尔
日期:2015-03-27 14:08:09
9 [报告]
发表于 2012-08-01 15:28 |只看该作者
回复 8# Third-Edition


    这个问题解决了,我找到模块文件了原来是c源文件我还以为是py文件找了半天没找着
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP