You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS安装uwsgi时出现undefined reference to ‘OpenSSL_version’错误

解决pip安装uwsgi时OpenSSL未定义引用错误

遇到的undefined reference to 'OpenSSL_version_num'这类错误,本质是编译uwsgi时无法正确链接OpenSSL库,或者Python编译时未正确关联OpenSSL依赖。以下是具体解决步骤:

1. 安装OpenSSL开发依赖包

首先确保系统安装了OpenSSL的头文件和库文件,这是编译依赖的基础:

  • Debian/Ubuntu系:
    sudo apt-get update && sudo apt-get install libssl-dev
    
  • CentOS/RHEL系:
    sudo dnf install openssl-devel  # 或 yum,取决于系统版本
    

2. 指定编译参数安装uwsgi

如果已经安装了开发包仍报错,通过环境变量强制指定OpenSSL的路径,让uwsgi编译时能找到对应库:

CFLAGS="-I/usr/include/openssl" LDFLAGS="-L/usr/lib64 -lssl -lcrypto" pip3 install uwsgi

注意:路径需根据系统调整,比如Ubuntu可能是/usr/lib/x86_64-linux-gnu,可以通过find / -name libssl.so查找实际库路径。

3. 重新编译Python(若为手动编译的Python)

你的Python是手动编译的/usr/local/python-3.11.2,如果编译时未指定OpenSSL路径,会导致Python静态库依赖缺失。需要重新编译Python并关联OpenSSL:

# 进入Python源码目录(假设是/root/Python-3.11.2)
cd /root/Python-3.11.2
# 清理之前的编译文件
make clean
# 配置编译参数,指定OpenSSL路径(这里以系统默认路径为例)
./configure --prefix=/usr/local/python-3.11.2 --with-openssl=/usr --with-openssl-rpath=auto
# 重新编译安装
make && sudo make install
# 之后再尝试安装uwsgi
pip3 install uwsgi

4. 备选:通过编译参数传递给uwsgi

也可以直接给pip传递uwsgi的编译选项:

pip3 install uwsgi --global-option="ssl" --global-option="-L/usr/lib64" --global-option="-I/usr/include/openssl"

内容的提问来源于stack exchange,提问作者Merklle Black

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 02:07:06