Theresa Arzadon-Labajo

Install OPAM on Springdale/RHEL/CentOS/SL 5.X

Posted by Theresa Arzadon-Labajo (tarzadon) on Feb 10 2014
Tech Stuff >> Unix-Linux

Short version:

In order to install OPAM on a 5.X machine, it needed at least OCaml version 3.12, which needed a newer binutils, which needed a newer GCC, which needed a new mpfr-devel.

On a 6.X machine, all you need to do is to download and install OCaml version 3.12 and OPAM.

Long version (beware of the rabbit hole):

I first tried to download OPAM and run the installer, which gave me the error:

        Initializing with compiler 4.01.0
        /usr/local/bin/opam: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by /usr/local/bin/opam)
        /usr/local/bin/opam: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/local/bin/opam)
        configure: error: You must install the Camlp4 pre-processor. On some operating systems, these are separate packages from the main OCaml compiler, such as camlp4-extra on Debian.

Installed camlp4 and try installing opam again with the same error.

# yum install camlp4

I downloaded the OPAM tar ball and then tried compiling it again:

# ./configure
OCaml version is 3.11.2
OCaml library path is /usr/lib64/ocaml
configure: error: You must install the Camlp4 pre-processor. On some operating systems, these are separate packages from the main OCaml compiler, such as camlp4-extra on Debian.

The default version on 5 and 6 machines is 3.11.2.

I then Downladed the 3.12 version from ocaml.org

cd /usr/local svn checkout http://caml.inria.fr/svn/ocaml/version/3.12 cd 3.12 ./configure .... BFD library not found, 'objinfo' will be unable to display info on .cmxs files

To get rid of the BFD library error:

# yum install binutils-devel

Re-run the configure and finish compiling:

# make world
# make bootstrap > log.bootstrap 2>&1
# make opt > log.opt 2>&1
# make opt.opt
# umask 022
# make install
# make clean

Now, when I tried to run configure again, I got:

        opam: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by opam)
        opam: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by opam)

Install GLIBC

# git clone git://sourceware.org/git/glibc.git
# cd glibc
# git branch -a
# git checkout --track -b local_glibc-2.14 origin/release/2.14/master
Checking out files: 100% (12834/12834), done.
# mkdir glibc-build
# cd glibc-build
# ../glibc/configure --prefix=/usr/local/mylib/
        ...
        running configure fragment for nptl/sysdeps/x86_64
        checking for .cfi_personality and .cfi_lsda pseudo-ops... no
        configure: error: assembler too old, .cfi_personality support missing

According to Employed Russian on this link configure: error: assembler too old, .cfi_personality support missing, binutils needed to be updated.

Download newer Binutils

# wget http://ftp.gnu.org/gnu/binutils/binutils-2.20.1.tar.bz2
# tar xjvf binutils-2.20.1.tar.bz2
​# ​cd binutils-2.20.1
# ./configure
# make && make install

Try configuring GLIBC again:

# ../glibc-2.14/configure --prefix=/usr/local/mylib/ --with-binutils=/usr/local
        ...
        checking cpuid.h usability... no
        checking cpuid.h presence... no
        checking for cpuid.h... no
        configure: error: gcc must provide the  header

According to krinn on crossdev fails to build glibc for ppc -- cpuid.h [Solved], a newer gcc would solve the problem.

Build a newer GCC

# svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch/ gcc-4.4
Checked out revision 207582.
# mkdir gcc-4.4-build
# cd gcc-4.4-build
# ../gcc-4.4/configure 
        configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
        Try the --with-gmp and/or --with-mpfr options to specify their locations.
        Copies of these libraries' source code can be found at their respective
        hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
        See also http://gcc.gnu.org/install/prerequisites.html for additional info.
        If you obtained GMP and/or MPFR from a vendor distribution package, make
        sure that you have installed both the libraries and the header files.
        They may be located in separate packages.

Now mpfr-devel needs to be built

# wget http://www.mpfr.org/mpfr-2.4.1/mpfr-2.4.1.tar.bz2
# tar xjvf mpfr-2.4.1.tar.bz2
# curl http://www.mpfr.org/mpfr-2.4.1/patches | patch -N -Z -p1
# ./configure
# make
# make check
# make install

Not sure if the following was needed, but found it on http://gcc.gnu.org/wiki/InstallingGCC: For RPM-based systems, including Fedora and SUSE, you should install gmp-devel, mpfr-devel and libmpc-devel (or mpc-devel on SUSE) packages. The packages will install the libraries and headers in standard system directories so they can be found automatically when building GCC. gmp-devel and mpfr-devel was already installed, so just install libmpc-devel:

# yum install libmpc-devel

Now back to building GCC

# ../gcc-4.4/configure --with-mpfr=/usr/local
configure: creating ./config.status
config.status: creating Makefile
# make
# make install

Now....back to installing GLIBC

# ../glibc-2.14/configure --prefix=/usr/local/mylib/ --with-binutils=/usr/local
# make
#  env LANGUAGE=C LC_ALL=C make install

And, back to the whole point of this exercise, which to install OPAM

# cd opam-full-1.1.1
# ./configure
        checking for gcc... /usr/local/bin/gcc
        ...
        checking whether /usr/local/bin/gcc accepts -g... yes
        ...
        config.status: creating Makefile.config
        config.status: creating src/core/opamVersion.ml
        config.status: creating doc/man-ext/opam-check.md

        Executables will be installed in /usr/local/bin
        Manual pages will be installed in /usr/local/share/man
 # make
        Build Successful in 13.00s. 840 jobs (parallelism 6.4x), 1124 files generated.
        make[1]: Leaving directory `/root/opam-full-1.1.1'

# make install
# opam init

Last changed: Feb 27 2020 at 4:02 PM

Back