我在非标准位置安装了自己的OpenSSL(/my/path出于本示例的目的),并且我希望针对源代码编译Python 3.4时可以以此为基础进行构建。我试过的是这个(目录缩写)
/my/path
CPPFLAGS="-I/my/path/include -I/my/path/include/openssl" ./configure --prefix=/my/path/
我也尝试了用C_INCLUDE_PATH冒号分隔的路径。
C_INCLUDE_PATH
然后,我运行make并得到以下信息:
make
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
它正在寻找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