使用 Python3.10 和 OpenSSL-1.1 编译 C:未定义的符号"OPENSSL_sk_num"



nginx/unit 的配置脚本失败,因为它无法编译如下所示的 python 扩展代码:

#include <Python.h>
int main() {
Py_Initialize();
return 0;
}

我正在使用使用 openssl-1.1.1 编译的 python3.10。 编译给出了几个符号未找到错误,包括"OPENSSL_sk_num"。似乎该符号在 libcrypto 中,我已经在编译命令中手动链接了它。

我是否需要再次编译 Python 以便在 libpython.a 中静态链接 libcrypto 和 libssl?下面是完整的编译命令。

cc -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -fstrict-aliasing -Wstrict-overflow=5 -Wmissing-prototypes -Werror -g -I/home/shared/Builds/Python-3.1
0.0/include/python3.10 -I/home/shared/Builds/Python-3.10.0/include/python3.10 -o build/autotest build/autotest.c -L/home/shared/Builds/Python-3.10.0/lib/python3.10/config-3.10 -L/home/shared/Buil
ds/Python-3.10.0/lib -lcrypto -lssl  -lpython3.10 -lpthread -lutil -lm -lm

幸运的是,找到了修复程序。以下作品 - 不知道为什么

cc -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -fstrict-aliasing -Wstrict-overflow=5 -Wmissing-prototypes -Werror -g -I/home/shared/Builds/Python-3.10.0/include/python3.10 -I/home/shared/Builds/Python-3.10.0/include/python3.10 -o build/autotest build/autotest.c -L/home/shared/Builds/Python-3.10.0/lib/  -lpython3.10  -lpthread -lutil -lm  -L/usr/local/lib/eopenssl11 -lssl -lcrypto  

-lpython3.10必须先于-lssl,先于-lcrypto

最新更新