
我之前发现的以前的答案都没有对我有用,但是我最终还是借助先前未提及的另一个答案来弄清楚了。这是实际的解决方法:https
:
//stackoverflow.com/a/20740964/2934226
基本上,CPPFLAGS和LDFLAGS不能在环境中设置。您需要在configure命令旁边进行设置,如下所示:
./configure CPPFLAGS="-I[openSSL install location]/include" LDFLAGS="-L[openSSL install location]/lib" [other flags here]
然后,在编译和安装后,它开始工作了!
$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"OpenSSL 1.0.2l 25 May 2017
以下是无效的原因以及原因:
如何使用自定义OpenSSL编译Python
3.4?这无济于事,因为您无法在环境中设置LDFLAGS,CFLAGS或CPPFLAGS;setup.py不会将它们传递给实际的编译步骤。即使设置LD_LIBRARY_PATH可能起作用,您也不想这样做,因为这很危险(请参阅http://xahlee.info/UnixResource_dir/_/ldpath.html)。最后,–with-
ssl不是有效的configure参数,并且在那里列出的用于添加它的补丁程序并不适用。
当您尝试从源代码构建某些东西,而不是试图获取一个已经编译的dylib来查找重定位的库时,Homebrew拒绝链接OpenSSL并不适用。此外,在/ usr /
local中建立符号链接是很危险的,并且可能导致程序针对较新的标头进行编译,但使用较旧的系统二进制文件。
如何在MacOS上将ssl与python
build包括在一起无法正常工作。编辑setup.py以添加lib和include目录(用于安装OpenSSL的
部分位置) ,并且可以在SSL支持中进行编译。las,它们不可导入,因为旧版本仍在使用:
Following modules built successfully but were removed because they could not be imported:_hashlib _ssl
[…]
building '_ssl' extensiongcc -Wno-unused-result -Wsign-compare -Wunreachable-pre -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I/usr/local/opt/openssl/include/ -I./Include -I/oebuild/python/python-3.6.1/include -I. -I/usr/local/include -I/oebuild/python/src/Python-3.6.1/Include -I/oebuild/python/src/Python-3.6.1 -c /oebuild/python/src/Python-3.6.1/Modules/_ssl.c -o build/temp.macosx-10.11-x86_64-3.6/oebuild/python/src/Python-3.6.1/Modules/_ssl.ogcc -bundle -undefined dynamic_lookup build/temp.macosx-10.11-x86_64-3.6/oebuild/python/src/Python-3.6.1/Modules/_ssl.o -L/oebuild/python/python-3.6.1/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.macosx-10.11-x86_64-3.6/_ssl.cpython-36m-darwin.sobuilding '_hashlib' extensiongcc -Wno-unused-result -Wsign-compare -Wunreachable-pre -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I/usr/local/opt/openssl/include/ -I./Include -I/oebuild/python/python-3.6.1/include -I. -I/usr/local/include -I/oebuild/python/src/Python-3.6.1/Include -I/oebuild/python/src/Python-3.6.1 -c /oebuild/python/src/Python-3.6.1/Modules/_hashopenssl.c -o build/temp.macosx-10.11-x86_64-3.6/oebuild/python/src/Python-3.6.1/Modules/_hashopenssl.ogcc -bundle -undefined dynamic_lookup build/temp.macosx-10.11-x86_64-3.6/oebuild/python/src/Python-3.6.1/Modules/_hashopenssl.o -L/oebuild/python/python-3.6.1/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.macosx-10.11-x86_64-3.6/_hashlib.cpython-36m-darwin.so*** WARNING: renaming "_ssl" since importing it failed: dlopen(build/lib.macosx-10.11-x86_64-3.6/_ssl.cpython-36m-darwin.so, 2): Symbol not found: _CRYPTO_THREADID_set_callback Referenced from: build/lib.macosx-10.11-x86_64-3.6/_ssl.cpython-36m-darwin.so Expected in: flat namespace in build/lib.macosx-10.11-x86_64-3.6/_ssl.cpython-36m-darwin.so*** WARNING: renaming "_hashlib" since importing it failed: dlopen(build/lib.macosx-10.11-x86_64-3.6/_hashlib.cpython-36m-darwin.so, 2): Symbol not found: _HMAC_CTX_copy Referenced from: build/lib.macosx-10.11-x86_64-3.6/_hashlib.cpython-36m-darwin.so Expected in: flat namespace in build/lib.macosx-10.11-x86_64-3.6/_hashlib.cpython-36m-darwin.so
otool -L显示问题:
$ otool -L build/lib.macosx-10.11-x86_64-3.6/_ssl.cpython-36m-darwin_failed.so build/lib.macosx-10.11-x86_64-3.6/_ssl.cpython-36m-darwin_failed.so: /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8) /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
(根据https://wiki.openssl.org/index.php/Manual:Threads(3)#HISTORY,版本1.0.0中引入了CRYPTO_THREADID
)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)