Ruby source installation cannot load such file – zlib (LoadError) and cannot load such file – openssl (LoadError) and gem No rule to make target `/include/ruby.h’, needed by `zlib.o’. Stop. Solution
My preconditions when a problem occurs
- Linux version: Linux version 3.10.0-862.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)) #1 SMP Fri Apr 20 16:44:24 UTC 2018
- gcc version: gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
- Ruby version: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
- gem version: 3.0.6
- Ruby installation method: source code installation and source code is not deleted
- The purpose of installing Ruby and gems: Use ruby to build a redis cluster
cannot load such file – zlib problem solving
the reason
- The zlib library is missing
- Ruby-zlib is missing
solve
- (When zlib is not installed) Download and install zlib
- I use the source code to install, by default it is installed to /usr/local/lib, I choose to use the root user to operate
- Install version zlib-1.2.11
- Download package
wget http://www.zlib.net/zlib-1.2.11.tar.gz
- Unzip the package
tar -zxvf zlib-1.2.11.tar.gz
- Enter the zlib source directory
cd zlib-1.2.11/
- Configuration
./configure
- make
make
- an examination
make check
- installation
make install
- Check whether it is successful (libz.a exists in the directory)
find /usr/local/lib -name libz.a
- Download package
- Install ruby-zlib
- Ruby source code provides the source code, directly find the corresponding directory to install
cd /root/ruby-2.6.5/ext/zlib
ruby ./extconf.rb
- If an error is reported checking for zlib.h… no or checking for deflateReset() in -lzlib… no
- then
ruby ./extconf.rb --with-zlib-dir =/usr/local/zlib
make
- If an error is reported make: *** No rule to make target
/include/ruby.h', needed by
zlib.o’. Stop. - According to the log, we know that zlib.o: $(top_srcdir)/include/ruby.h to check the source code, if there is indeed no variable value
- In the first line of the Makefile document, set the path of the variable top_srcdir
- (I adopted) Replace $(top_srcdir) with absolute/relative path
- It is recommended to backup Makefile first
vim Makefile
: %s/$(top_srcdir)/..\/../g
:wq
- If an error is reported make: *** No rule to make target
- If an error was reported by make in the previous step, please modify it again
make
make install
- Ruby source code provides the source code, directly find the corresponding directory to install
cannot load such file – openssl problem solving
the reason
- Openssl-devel is not installed
- Lack of ruby-openssl
solve
- (When openssl is not installed) download and install openssl
- I use the source code installation, the default installation is /usr/local/ssl, and there is no link command
- Installed version openssl-1.0.2t
- Download package
wget https://www.openssl.org/source/openssl-1.0.2t.tar.gz
- Unzip the package
tar -zxvf openssl-1.0.2t.tar.gz
- Enter the catalog
cd openssl-1.0.2t
./config shared zlib
make depend
make
make install
- Verify that the installation is successful (display version information)
/usr/local/ssl/bin/openssl version -a
- If necessary, you can manually link the openssl command
- First confirm that /usr/bin/openssl and /usr/include/openssl do not exist, if they exist, please backup or delete the original openssl
- (Optional) Backup method
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
- (Optional) Backup method
- Link to the openssl you just installed
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
- (Optional) Write ld.so.conf to record the path of the dynamic library
echo “/usr/local/ssl/lib” >> /etc/ld.so.conf
ldconfig -v
- Verify that the link is successful openssl version -a
- First confirm that /usr/bin/openssl and /usr/include/openssl do not exist, if they exist, please backup or delete the original openssl
- Download package
- Install ruby-openssl
- Ruby source code provides the source code, directly find the corresponding directory to install
cd /root/ruby-2.6.5/ext/openssl
ruby ./extconf.rb
- (The newly installed openssl may not be linked) Error checking for openssl.h… no or checking for deflateReset() in -openssl… no
- then
ruby ./extconf.rb --with-openssl-dir=/usr/local/ssl
make
- If an error is reported make: *** No rule to make target
/include/ruby.h', needed by
zlib.o’. Stop. - According to the log, we know that zlib.o: $(top_srcdir)/include/ruby.h to check the source code. If there is indeed no variable value, the processing method is the same as installing ruby-zlib
- In the first line of the Makefile document, set the path of the variable top_srcdir
- (I adopted) Replace $(top_srcdir) with absolute/relative path
- It is recommended to backup Makefile first
vim Makefile
: %s/$(top_srcdir)/..\/../g
: wq
- If an error is reported make: *** No rule to make target
- If an error was reported by make in the previous step, please modify it again
make
make install
- Ruby source code provides the source code, directly find the corresponding directory to install
No rule to make target /include/ruby.h', needed by
zlib.o’. Stop. Solution
the reason
- It may be that the corresponding value of the $(top_srcdir)/include/ruby.h variable is missing
solve
- If an error is reported make: *** No rule to make target
/include/ruby.h', needed by
zlib.o’. Stop. - According to the log, we know that zlib.o: $(top_srcdir)/include/ruby.h to check the source code, if there is indeed no variable value
- In the first line of the Makefile document, set the path of the variable top_srcdir
- (I adopted) Replace $(top_srcdir) with absolute/relative path
- It is recommended to backup Makefile first
cp Makefile Makefile.bak
vim Makefile
: %s/$(top_srcdir)/..\/../g
: wq
- It is recommended to backup Makefile first
Similar Posts:
- zlib.h:no such file or directory
- Openeuler: How to Install OpenSSL
- Quick resolution of gem install redis error
- Make Command ERROR: “make:*** No targets specified and no makefile found.Stop.” [Three Method to Solve]
- Python3 ImportError: No module named _ssl [How to Solve]
- [Solved] Accessing MSSql under Ubuntu prompts SSL Handshake failed with OpenSSL error
- Python Installation WARNING: pip is configured with locations that require TLS/SSL, however the ssl module…
- Python Via get-pip.py Install pip Error: zipimport.ZipImportError: can‘t decompress data; zlib not availabl
- PHP5.6.27 Install error: error: dereferencing pointer to incomplete type ‘EVP_PKEY’ {aka ‘struct evp_pkey_st’}
- /usr/bin/ld: cannot find -lz