【问题标题】:Compiling C with Python3.10 and OpenSSL-1.1: undefined symbol "OPENSSL_sk_num"用 Python3.10 和 OpenSSL-1.1 编译 C:未定义符号“OPENSSL_sk_num”
【发布时间】:2022-01-01 23:34:28
【问题描述】:

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

【问题讨论】:

    标签: python c openssl ld


    【解决方案1】:

    幸运的是,找到了解决方法。以下作品 - 不知道为什么

    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 之前。

    【讨论】:

      猜你喜欢
      • 2017-06-25
      • 2013-03-07
      • 2017-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多