[英]Building OpenSSL to compile portable version of Python
I am trying to build Python from source and need to include the SSL module for my web scraper to work with it. 我正在尝试从源代码构建Python,并且需要包括SSL模块,以便我的网络抓取工具可以使用它。
I ran into the problem of SSL not being found, so I downloaded and built OpenSSL from source. 我遇到了找不到SSL的问题,因此我从源代码下载并构建了OpenSSL。 The problem is, I need to install the development libraries along with OpenSSL in order for Python to run the
-lssl
parameter correctly when running make
. 问题是,我需要与OpenSSL一起安装开发库,以便Python在运行
make
时正确运行-lssl
参数。 I can't seem to find any documentation on how to build OpenSSL with the development libs, even though I'm sure it's got to be something simple I'm just missing. 我似乎找不到任何有关如何使用开发库构建OpenSSL的文档,即使我确定它一定很简单,我只是想念它。
I must do this from source; 我必须从源头上做到这一点; with no package managers.
没有包管理器。 I have my reasons.
我有我的理由。
EDIT: I have changed a few of the python configuration settings to try and fix the problem, and this is the compile error I am getting now: 编辑:我已经更改了一些python配置设置以尝试解决问题,这是我现在得到的编译错误:
gcc -pthread -Xlinker -export-dynamic -o python \\ Modules/python.o \\ libpython2.7.a -lpthread -ldl -lutil -L/home/[username]/openssl-src -lssl -lcrypto -lm
libpython2.7.a(posixmodule.o)(.text+0x4016): In function posix_tmpnam':<br /> ./Modules/posixmodule.c:7346: warning: the use of
tmpnam_r' is dangerous, better use mkstemp' libpython2.7.a(posixmodule.o)(.text+0x3f76): In function
posix_tempnam': ./Modules/posixmodule.c:7301: warning: the use of tempnam' is dangerous, better use
mkstemp'
./python: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
make: * [sharedmods] Error 127
The "no such file or directory" is being thrown looking for a file that does exist in the /home/[username]/openssl-src
directory. 查找“
/home/[username]/openssl-src
目录中确实存在的文件”时,抛出“没有这样的文件或目录”。
The default OpenSSL build should install the appropriate header files and libraries using make install
, just make sure to provide the right prefix to the configure script (eg, ./configure --prefix=/usr
). 默认的OpenSSL构建应使用
make install
适当的头文件和库,只需确保为configure脚本提供正确的前缀(例如./configure --prefix=/usr
)。
If this fails, please post the exact error that gcc shows. 如果失败,请发布gcc显示的确切错误。
By the way, please consider using an automated tool such as buildout for building Python. 顺便说一下,请考虑使用诸如buildout之类的自动化工具来构建Python。 I think the standard recipes take care of SSL support (possibly even downloading and compiling OpenSSL), although I am not certain about this.
我认为标准配方可以照顾到SSL支持(甚至可能下载并编译OpenSSL),尽管我对此不确定。
This answer doesn't EXACTLY answer my question, but I did find out what I needed to know so I will post it here. 这个答案不能完全回答我的问题,但是我确实找到了我需要知道的内容,因此将其发布在这里。 I had to change the location of the SSL files it was looking for to just
/usr
rather than /usr/local
. 我不得不将要查找的SSL文件的位置更改为
/usr
而不是/usr/local
。 RedHat by default has all the shared libraries in /usr/lib
rather than /usr/local/lib
, which is where it was looking by default. 默认情况下,RedHat在
/usr/lib
具有所有共享库,而不是在/usr/local/lib
,这是它默认查找的位置。
in the Bourne shell (/bin/sh or /bin/bash): 在Bourne Shell(/ bin / sh或/ bin / bash)中:
$ LD_LIBRARY_PATH=/usr/local/lib
$ export LD_LIBRARY_PATH
$ make
in the C-shell (/bin/csh or /bin/tcsh): 在C-shell(/ bin / csh或/ bin / tcsh)中:
% setenv LD_LIBRARY_PATH /usr/local/lib
% make
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.