繁体   English   中英

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

[英]Compiling C with Python3.10 and OpenSSL-1.1: undefined symbol "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之前。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM