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

GCC未关联正确OpenSSL版本问题(多版本共存场景)

问题:编译后的程序调用的OpenSSL版本与预期不符

安装OpenSSL 3.3.1的操作步骤

通过源码编译安装OpenSSL 3.3.1,执行的命令如下:

./config '-Wl,-rpath,$(LIBRPATH)' -Wl,--enable-new-dtags --prefix=/usr/local --openssldir=/usr/local/openssl
make
make install

测试程序test.c

编写了如下测试代码,用于打印当前使用的OpenSSL版本:

#include <stdio.h>
#include <openssl/ssl.h>
int main()
{
    printf("Openssl Version: %s\n", OpenSSL_version(OPENSSL_VERSION));
}

编译命令与运行现象

使用以下命令编译测试程序:

gcc test.c -o t -v -I/usr/local/include -L/usr/local/lib64/ -lssl -lcrypto

编译完成后运行程序,输出的OpenSSL版本为3.0.2,而非预期的3.3.1。

环境说明

  • Ubuntu系统预装了OpenSSL 3.0.2,位于/usr/bin目录,执行openssl version返回3.0.2;
  • 手动安装的OpenSSL 3.3.1位于/usr/local/bin,执行/usr/local/bin/openssl version返回3.3.1;
  • 已确认/usr/local/include目录包含OpenSSL 3.3.1的头文件,/usr/local/lib64目录存在对应的库文件;
  • 已保留gcc -v的编译日志。

疑问

为什么会出现这种版本不符的情况?我的操作哪里存在错误?

内容的提问来源于stack exchange,提问作者Mattia Terenzi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 14:02:05