C/C++教程

centos环境提示「openssl/ssl.h: No such file or directory」解决方法

本文主要是介绍centos环境提示「openssl/ssl.h: No such file or directory」解决方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

文章目录

    • 问题描述
    • 解决方法
    • 相关问题
      • openssl-devel安装过程中报错
      • 参考

问题描述

在docker镜像(centos系统)中,编译代码时,有如下错误

fatal error: openssl/ssl.h: No such file or directory
#include <openssl/ssl.h>                   // SSL_*

解决方法

找不到 openssl/ssl.h 头文件是因为 openssl-devel 缺失导致的,安装该库即可,可用如下命令:
sudo yum install -y openssl-devel

  • 安装完成后,可以通过 sudo yum list installed | grep openssl-devel 查看是否安装成功。
  • 安装前可以通过sudo yum info openssl-devel 查看源中对应的版本

相关问题

openssl-devel安装过程中报错

使用『sudo yum install openssl-devel -y』安装openssl-dev过程中有相关依赖包安装失败,如下

...
--> Finished Dependency Resolution
Error: Package: libselinux-devel-2.5-6.el7.x86_64 (base)
           Requires: libselinux(x86-64) = 2.5-6.el7
           Installed: libselinux-2.5-15.el7.x86_64 (@base)
               libselinux(x86-64) = 2.5-15.el7
           Available: libselinux-2.5-6.el7.x86_64 (base)
               libselinux(x86-64) = 2.5-6.el7
Error: Package: libsepol-devel-2.5-6.el7.x86_64 (base)
           Requires: libsepol(x86-64) = 2.5-6.el7
           Installed: libsepol-2.5-10.el7.x86_64 (@base)
               libsepol(x86-64) = 2.5-10.el7
           Available: libsepol-2.5-6.el7.x86_64 (base)
               libsepol(x86-64) = 2.5-6.el7
Error: Package: 1:openssl-devel-1.0.1e-60.el7_3.1.x86_64 (updates)
           Requires: openssl-libs(x86-64) = 1:1.0.1e-60.el7_3.1
           Installed: 1:openssl-libs-1.0.2k-21.el7_9.x86_64 (@updates)
               openssl-libs(x86-64) = 1:1.0.2k-21.el7_9
           Available: 1:openssl-libs-1.0.1e-60.el7.x86_64 (base)
               openssl-libs(x86-64) = 1:1.0.1e-60.el7
           Available: 1:openssl-libs-1.0.1e-60.el7_3.1.x86_64 (updates)
               openssl-libs(x86-64) = 1:1.0.1e-60.el7_3.1
 You could try using --skip-broken to work around the problem
** Found 5 pre-existing rpmdb problem(s), 'yum check' output follows:
glibc-2.17-157.el7_3.1.x86_64 is a duplicate with glibc-2.17-157.el7.x86_64
glibc-common-2.17-157.el7_3.1.x86_64 is a duplicate with glibc-common-2.17-157.el7.x86_64
glibc-devel-2.17-157.el7.x86_64 has missing requires of glibc-headers = ('0', '2.17', '157.el7')
glibc-devel-2.17-157.el7_3.1.x86_64 is a duplicate with glibc-devel-2.17-157.el7.x86_64
glibc-utils-2.17-157.el7_3.1.x86_64 is a duplicate with glibc-utils-2.17-157.el7.x86_64

解决方法:

  • 切换源,以下切换为aliyun源,相关命令为:
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo yum clean all
sudo yum makecache
sudo yum install -y openssl-devel

参考

  • centos7 yum 切换成阿里源
  • 【解决:fatal error: openssl/ssl.h: No such file or directory】
这篇关于centos环境提示「openssl/ssl.h: No such file or directory」解决方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!