Mir S Mehdi
Mir S Mehdi

Reputation: 1530

"openssl/ssl.h: No such file or directory" during Installation of Git

Trying to install git on the Unix and Linux machines based on the instructions on Installing Git blog, and it is failing with the below error

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.

I do not have yum/apt-get on my machines to run the below commands as suggested:

$ 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.

Upvotes: 51

Views: 173116

Answers (7)

satya prakash patel
satya prakash patel

Reputation: 550

For Ubuntu I installed openssl and libssl-dev

sudo apt install openssl libssl-dev

After checking configure file code, I found it is searching for include/openssl/ssl.h in predefined paths

You can find it on your system and can run configure with --with-openssl

E.g. if you found ssl.h in /usr/include/openssl/ssl.h then you can run below command

./configure --with-openssl=/usr/

Upvotes: 13

VonC
VonC

Reputation: 1324937

Since 2013 (year of the question on this page), make sure to use a recent enough version of curl.

With Git 2.34 (Q4 2021), conditional compilation around versions of libcURL has been straightened out.

See commit 32da6e6, commit e4ff3b6, commit 905a028, commit 2a7f646, commit 7ce3dcd, commit 2d4032c, commit 59a399e (13 Sep 2021), and commit e54e502, commit 5b95244 (11 Sep 2021) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit 8f79fb6, 23 Sep 2021)

http: don't hardcode the value of CURL_SOCKOPT_OK

Signed-off-by: Ævar Arnfjörð Bjarmason

Use the new git-curl-compat.h header to define CURL_SOCKOPT_OK to its known value if we're on an older curl version that doesn't have it.
It was hardcoded in http.c in a15d069 ("http: enable keepalive on TCP sockets", 2013-10-12, Git v1.8.5-rc0 -- merge).

Upvotes: 0

user2959786
user2959786

Reputation: 101

The following fixed compiling 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

Upvotes: 2

Drummermean
Drummermean

Reputation: 209

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:

Get the source code, unpack it, enter the directory and make a build directory (very important):

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:

./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:

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:

which openssl
> /home/yourdir/openssl-1.0.2r/builddir/bin/openssl

Now try and reinstall git, perhaps with make distclean.

Upvotes: 6

王京东
王京东

Reputation: 421

For RHEL and RHEL-derivatives like CentOS systems, installing will solve this problem.

$ yum install -y openssl-devel

Upvotes: 32

thais dbraz
thais dbraz

Reputation: 871

this answer worked just fine for me

https://stackoverflow.com/a/3016986/5837509

just do sudo apt-get install libssl-dev

Upvotes: 76

tripleee
tripleee

Reputation: 189477

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).

Also:

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/openssl shows you which packages the openssl Debian package depends on; some of those will have a similar list of dependencies of their own, in turn.

Upvotes: 2

Related Questions