安装 Git 期间出现“openssl/ssl.h: No such file or directory”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17915098/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"openssl/ssl.h: No such file or directory" during Installation of Git
提问by Mir S Mehdi
Trying to install git on the Unix and Linux machines based on the instructions on Installing Gitblog, and it is failing with the below error
尝试根据安装 Git博客上的说明在 Unix 和 Linux 机器上安装 git,但失败并显示以下错误
make prefix=/usr/local all
GIT_VERSION = 1.8.3.4
* new build flags
CC credential-store.o
In file included from cache.h:4,
from credential-store.c:1:
git-compat-util.h:221:25: warning: openssl/ssl.h: No such file or directory
git-compat-util.h:222:25: warning: openssl/err.h: No such file or directory
In file included from credential-store.c:1:
cache.h:11:21: warning: openssl/sha.h: No such file or directory
cache.h:19:18: warning: zlib.h: No such file or directory
In file included from credential-store.c:1:
cache.h:21: syntax error before "z_stream"
cache.h:21: warning: no semicolon at end of struct or union
cache.h:28: syntax error before '}' token
cache.h:28: warning: type defaults to `int' in declaration of `git_zstream'
cache.h:28: warning: data definition has no type or storage class
cache.h:30: syntax error before '*' token
cache.h:31: syntax error before '*' token
cache.h:32: syntax error before '*' token
cache.h:33: syntax error before '*' token
cache.h:35: syntax error before '*' token
cache.h:36: syntax error before '*' token
cache.h:37: syntax error before '*' token
cache.h:38: syntax error before '*' token
cache.h:39: syntax error before '*' token
cache.h:40: syntax error before '*' token
cache.h:41: syntax error before '*' token
cache.h:42: syntax error before '*' token
cache.h:769: syntax error before '*' token
make: *** [credential-store.o] Error 1
I know this is because of the missing libraries for openssl, but I am unable to get these libraries.
我知道这是因为缺少 openssl 库,但我无法获得这些库。
I do not have yum/apt-get on my machines to run the below commands as suggested:
我的机器上没有 yum/apt-get 来按照建议运行以下命令:
$ yum install curl-devel expat-devel gettext-devel \
openssl-devel zlib-devel
$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
libz-dev libssl-dev
What do I do get these libraries on these machines. These machines do not have internet access, I can do a scp if required. Any suggestions.
我该怎么做才能在这些机器上获取这些库。这些机器没有互联网访问权限,如果需要,我可以做一个 scp。有什么建议。
回答by thais dbraz
this answer worked just fine for me
这个答案对我来说很好用
https://stackoverflow.com/a/3016986/5837509
https://stackoverflow.com/a/3016986/5837509
just do sudo apt-get install libssl-dev
做就是了 sudo apt-get install libssl-dev
回答by Reader Useless
For RHEL and RHEL-derivatives like CentOS systems, installing will solve this problem.
对于 RHEL 和 RHEL 衍生品如 CentOS 系统,安装将解决此问题。
$ yum install -y openssl-devel
回答by Drummermean
If you can't access yum, apt-get etc (such as being on a cluster machine with no sudo access), install a new version of openssl locally and manually as follows:
如果无法访问yum、apt-get等(例如在没有sudo访问权限的集群机器上),请在本地手动安装新版本的openssl,如下所示:
Get the source code, unpack it, enter the directory and make a build directory (veryimportant):
获取源码,解压,进入目录,制作build目录(很重要):
wget https://www.openssl.org/source/openssl-1.0.2r.tar.gz
tar -xvzf openssl-1.0.2r.tar.gz
cd openssl-1.0.2r
mkdir builddir
Configure to your local build destination (make sure its different to your source directory, don't use just /home/yourdir/openssl-1.0.2r/), make and install:
配置到您的本地构建目标(确保它与您的源目录不同,不要只使用 /home/yourdir/openssl-1.0.2r/),制作并安装:
./config --prefix=/home/yourdir/openssl-1.0.2r/builddir --openssldir=/home/yourdir/openssl-1.0.2r/builddir
make
make install
Add the bin and library paths from the build directory to the appropriate variables in your your shell config file (i.e. ~/.bashrc), and source it:
将构建目录中的 bin 和库路径添加到 shell 配置文件(即 ~/.bashrc)中的适当变量中,并获取它:
export PATH=/home/yourdir/openssl-1.0.2r/builddir/bin:$PATH
LD_LIBRARY_PATH="/your/other/dirs/libs:/home/yourdir/openssl-1.0.2r/builddir/lib:"
source ~/.bashrc
OpenSSL should now be in your new directory by default:
默认情况下,OpenSSL 现在应该在您的新目录中:
which openssl
> /home/yourdir/openssl-1.0.2r/builddir/bin/openssl
Now try and reinstall git, perhaps with make distclean.
现在尝试重新安装 git,也许使用 make distclean。
回答by satya prakash patel
For ubuntui installed openssland libssl-dev
对于ubuntu,我安装了openssl和libssl-dev
sudo apt install openssl libssl-dev
sudo apt 安装 openssl libssl-dev
After checking configure file code, i found it is searching for "include/openssl/ssl.h"in predefined paths
检查配置文件代码后,我发现它在预定义路径中搜索“include/openssl/ssl.h”
You can find it on your system and can run configure with --with-openssl
您可以在您的系统上找到它,并可以使用 --with-openssl 运行配置
E.g. if you found ssl.h in /usr/include/openssl/ssl.h then you can run below command
例如,如果您在 /usr/include/openssl/ssl.h 中找到了 ssl.h,那么您可以运行以下命令
./configure --with-openssl=/usr/
./configure --with-openssl=/usr/
回答by tripleee
If you do not have access to prebuilt packages for the required libraries, you have to resort to the age-old practice from before there were package managers: Build the libraries locally, and the libraries they depend on, and the libraries they depend on, and so on.
如果您无法访问所需库的预构建包,则必须采用包管理器出现之前的古老做法:在本地构建库,以及它们所依赖的库,以及它们所依赖的库,等等。
In other words, you are in for a potentially large and complex maze of dependency chasing, which might include fixing portability bugs for your platform if the source does not compile out of the box.
换句话说,如果源代码不是开箱即用的,您将陷入一个潜在的庞大而复杂的依赖追逐迷宫,其中可能包括修复平台的可移植性错误。
The Debian PTS has links to upstream projects for many packages, so you might not need to guess which result to pick out of Google results for "openssl source". See e.g. http://packages.qa.debian.org/o/openssl.html(the "Browse source code" link is a good start; the Debian Copyright file for each package should also contain an upstream URL, although it may be historical).
Debian PTS 有许多包的上游项目的链接,因此您可能不需要猜测从“openssl 源”的 Google 搜索结果中挑选哪个结果。参见例如http://packages.qa.debian.org/o/openssl.html(“浏览源代码”链接是一个好的开始;每个包的 Debian 版权文件也应该包含一个上游 URL,尽管它可能是历史)。
Also:
还:
- http://packages.qa.debian.org/c/curl.html
- http://packages.qa.debian.org/e/expat.html
- http://packages.qa.debian.org/g/gettext.html
- http://packages.qa.debian.org/z/zlib.html
- http://packages.qa.debian.org/c/curl.html
- http://packages.qa.debian.org/e/expat.html
- http://packages.qa.debian.org/g/gettext.html
- http://packages.qa.debian.org/z/zlib.html
If you have a package manager locally (on Debian, that would be the basic dpkg
) then you can avoid the finding and compiling morass, and just copy the required hierarchy of depended packages from an Internet-connected host; but again, make sure you get the full set of recursive dependencies (anything that a package you depend on in turn depends on, recursively). E.g. https://packages.debian.org/stable/opensslshows you which packages the openssl
Debian package depends on; some of those will have a similar list of dependencies of their own, in turn.
如果您在本地有一个包管理器(在 Debian 上,那将是基本的dpkg
),那么您可以避免查找和编译的麻烦,只需从连接 Internet 的主机复制所需的依赖包层次结构;但同样,请确保您获得完整的递归依赖项(您依赖的包反过来依赖的任何东西,递归地)。例如https://packages.debian.org/stable/openssl显示openssl
Debian 软件包依赖哪些软件包;其中一些将依次具有类似的依赖项列表。
回答by user2959786
The following fixed compiling python 3.8.1 with ssl
以下固定编译python 3.8.1 with ssl
locate ssl.h
/usr/include/openssl/ssl.h
$ pwd
/var/opt/python381/Python-3.8.1
$ ln -s /usr/include/openssl
Result
结果
./configure
~~
checking whether compiling and linking against OpenSSL works... yes
checking for X509_VERIFY_PARAM_set1_host in libssl... yes