我如何编译Python 3.4与自定义OpenSSL? [英] How do I compile Python 3.4 with custom OpenSSL?

查看:695
本文介绍了我如何编译Python 3.4与自定义OpenSSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在非标准位置(本例中为 / my / path )安装了自己的OpenSSL,并且我希望Python 3.4能够在此时进行构建我根据源代码编译它。我试过的是这个(目录缩写)

  CPPFLAGS = -  I / my / path / include -I / my / path / include / openssl./configure --prefix = / my / path / 

C_INCLUDE_PATH 和冒号分隔的路径。

然后,我运行 make

 建立'_ssl'扩展名
gcc -pthread -fPIC -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I./Include -I。 -I包括-I / my / path / include -I / my / path / include / openssl -I / usr / local / include -I / my / path / Python-3.4.0 / Include -I / my / path / Python -3.4.0 -c /my/path/Python-3.4.0/Modules/_ssl.c -o build / temp.linux-x86_64-3.4 / my / path / Python-3.4.0 / Modules / _ssl.o
gcc -pthread -shared build / temp.linux-x86_64-3.4 / my / path / Python-3.4.0 / Modules / _ssl.o -L / my / path / lib -L ​​/ usr / local / lib - lssl -lcrypto -o build / lib.linux-x86_64-3.4 / _ssl.cpython-34m.so
***警告:自从导入失败后重命名_ssl:build / lib.linux-x86_64-3.4 / _ssl.cpython-34m.so:未定义符号:SSL_get0_next_proto_negotiated

它正在寻找 SSL_get0_next_proto_negotiated ,但这是最确定的:

  $ grep SSL_get0_next_proto_negotiated / my / path / include / openssl / * 
/my/path/include/openssl/ssl.h:void SSL_get0_next_proto_negotiated(const SSL * s,

我不知道我做错了什么,有什么想法吗?

我在经过很多发拉后才弄清楚了。这是一堆环境变量......我想我可能已经做了一些矫枉过正的工作,但是这基本上可行: OpenSSL 1.0.1g
./config shared --prefix = / my / path --openssldir = / my / path / openssl
make
make install

# Python 3.4
export LDFLAGS = - L / my / path / lib / -L / my / path / lib64 /
export LD_LIBRARY_PATH =/ my / path / lib /:/ my / path / lib64 /
export CPPFLAGS = - I / my / path / include -I / my / path / include / openssl
./configure --prefix = / my / path /
make
make install


I have my own OpenSSL installation in a non-standard location (/my/path for the sake of this example) and I want Python 3.4 to build against that when I compile it against source. What I tried is this (directories abbreviated)

CPPFLAGS="-I/my/path/include -I/my/path/include/openssl" ./configure --prefix=/my/path/

I also tried with C_INCLUDE_PATH and colon separated paths.

Then, I run make and get this:

building '_ssl' extension
gcc -pthread -fPIC -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I./Include -I. -IInclude -I/my/path/include -I/my/path/include/openssl -I/usr/local/include -I/my/path/Python-3.4.0/Include -I/my/path/Python-3.4.0 -c /my/path/Python-3.4.0/Modules/_ssl.c -o build/temp.linux-x86_64-3.4/my/path/Python-3.4.0/Modules/_ssl.o
gcc -pthread -shared build/temp.linux-x86_64-3.4/my/path/Python-3.4.0/Modules/_ssl.o -L/my/path/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-3.4/_ssl.cpython-34m.so
*** WARNING: renaming "_ssl" since importing it failed: build/lib.linux-x86_64-3.4/_ssl.cpython-34m.so: undefined symbol: SSL_get0_next_proto_negotiated

It's looking for SSL_get0_next_proto_negotiated, but that's most certainly defined:

$ grep SSL_get0_next_proto_negotiated /my/path/include/openssl/*
/my/path/include/openssl/ssl.h:void SSL_get0_next_proto_negotiated(const SSL *s,

I'm not sure what I'm doing wrong, any ideas?

解决方案

I managed to figure it out after a lot of hair-pulling. It was a bunch of environment variables... I think I might have done a little overkill, but this basically worked:

# OpenSSL 1.0.1g
./config shared --prefix=/my/path --openssldir=/my/path/openssl
make
make install

# Python 3.4
export LDFLAGS="-L/my/path/lib/ -L/my/path/lib64/"
export LD_LIBRARY_PATH="/my/path/lib/:/my/path/lib64/"
export CPPFLAGS="-I/my/path/include -I/my/path/include/openssl"
./configure --prefix=/my/path/
make
make install

这篇关于我如何编译Python 3.4与自定义OpenSSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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