簡體   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