Showing posts with label GNU Compilers. Show all posts
Showing posts with label GNU Compilers. Show all posts

Monday, November 23, 2015

Configure Error when compiling GCC 5.2.0 on CentOS 6.6

When I compile according to Compiling GNU 5.2.0 on CentOS 6

I've got this error.
configure: error: 
I suspect your system does not have 32-bit development libraries (libc and headers). 
If you have them, rerun configure with --enable-multilib. 
If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.

The solution is

# yum install glibc-devel*.i686

Tuesday, November 18, 2014

Install GCC 4.8.1 and other Scientitic Packages via Yum on CentOS

Do take a look at Linux @ CERN for the documentation on how to use yum to install devtoolset which contain the following packages. The latest version for CentOS 6 is devtoolset-2.1. Here is a summary of the Linux @ CERN

CentOS 6 / SL 6

Developer Toolset 2.1 provides following tools:
  • gcc/g++/gfortran - GNU Compiler Collection - version 4.8.2
  • gdb - GNU Debugger - version 7.6.34
  • binutils - A GNU collection of binary utilities - version 2.23.52
  • elfutils - A collection of utilities and DSOs to handle compiled objects - version 0.155
  • dwz - DWARF optimization and duplicate removal tool - version 0.11
  • systemtap - Programmable system-wide instrumentation system - version 2.1
  • valgrind - Tool for finding memory management bugs in programs - version 3.8.1
  • oprofile - System wide profiler - version 0.9.8
  • eclipse - An Integrated Development Environment - version 4.3.1 (Kepler)

CentOS 5 / SL 5

Developer Toolset 1.1 provides following tools:
  • gcc/g++/gfortran - GNU Compiler Collection - version 4.7.2
  • gdb - GNU Debugger - version 7.5
  • binutils - A GNU collection of binary utilities - version 2.23.51
  • elfutils - A collection of utilities and DSOs to handle compiled objects - version 0.154
  • dwz - DWARF optimization and duplicate removal tool - version 0.7
  • systemtap - Programmable system-wide instrumentation system - version 1.8
  • valgrind - Tool for finding memory management bugs in programs - version 3.8.1
  • oprofile - System wide profiler - version 0.9.7

Installation and Enablement

CentOS 6 / SL 6
Save repository information as /etc/yum.repos.d/slc6-devtoolset.repo on your system:
# cd /etc/yum.repos.d/ 
# wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
# yum install devtoolset-2 --nogpgcheck
# scl enable devtoolset-2 bash

CentOS 5 / SL 5
Save repository information as /etc/yum.repos.d/slc5-devtoolset.repo on your system:
# cd /etc/yum.repos.d/
# wget -O /etc/yum.repos.d/slc5-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc5-devtoolset.repo
# yum install devtoolset-1.1
# scl enable devtoolset-1.1 bash

Wednesday, October 23, 2013

Compiling GNU Scientific Library (GSL) gsl-1.16 on CentOS 6

The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers. It is free software under the GNU General Public License.
The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite.

Step 1: The current version of GSL is gsl-1.16.tar.gz

Step 2: You may want to use the latest GCC 4.8.1 to compile. For more information on how to compile GCC 4.8.1, see Compiling GNU 4.8.1 on CentOS 6. This compilation will help to fix all the components required for gsl-1.16

Step 3: After packing gsl, To compile
# cd /root/gsl-1.15/
# mkdir build-gsl
# cd build-gsl
# ../configure --prefix=/usr/local/gsl-1.16/
# make 
# make install

Tuesday, October 22, 2013

Compiling Error "Could not run a simple Fortran 77 program. Aborting." when compiling OpenMPI 1.6.5 with GCC 4.8.1 on CentOS 6

I was compiling OpenMPI 1.6.5 with GCC 4.8.1 on CentOS 6.3, I encountered this error "Could not run a simple Fortran 77 program. Aborting."

For more information on compiling GCC, do take a look at  Compiling GNU 4.8.1 on CentOS 6


A quick look, shows that my .bashrc was incorrect written. My PATH and LD_LIBRARY_PATH should reflect the pathing of GCC

export PATH=$PATH:/usr/local/gcc-4.8.2/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gcc-4.8.1/lib

Secondly, another possible issue could be due to incomplete or unlinked gfortran libraries. Do check with your /usr/local/gcc-4.8.1 that your libgfortran.so.3 is linked and present with the right libraries.


 Lastly, you can force the OpenMPI to compile F77 and FC with the following configuration
# ./configure --prefix=/usr/local/openmpi-1.6.5-gcc-4.8.1 \ 
F77=gfortran FC=gfortran --with-devel-headers --enable-binaries

Saturday, October 12, 2013

Encountering error -static-libstdc++ not implemented when compiling GNU 4.8.1 on CentOS 6

When compiling GNU 4.8.1 according to blog entry Compiling GNU 4.8.1 on CentOS 6, you may encounter an error in the config.log

.....
g++: unrecognized option '-static-libstdc++'
conftest.cpp:11:2: error: #error -static-libstdc++ not implemented
.....

The error indicate that you may missed packages such as glibc-static, glibc-devel, glibc-static, libstdc++ libstdc++-devel.

# yum install  glibc-static glibc-devel glibc-static libstdc++ libstdc++-devel

Another thing you may want to check is that the /etc/ld.so.conf.d has /usr/lib

Sunday, September 22, 2013

Compiling GNU 4.7.2 on CentOS 5

Step 1: Download the following prerequistics applications libraries from ftp://gcc.gnu.org/pub/gcc/infrastructure/
  1. gmp-4.3.2.tar.bz2
  2. mpfr-2.4.2.tar.bz2
  3. mpc-0.8.1.tar.gz
1. Install gmp-4.3.2
# bunzip2 gmp-4.3.2.tar.bz2
# tar -zxvf gmp-4.3.2.tar
# cd gmp-4.3.2
# ./configure --prefix=/usr/local/gmp-4.3.2
# make
# make install

2. Install mpfr-2.4.2 (requires gmp-4.3.2 as prerequisites)
# bunzip2 mpfr-2.4.2.tar.bz2
# tar -zxvf mpfr-2.4.2.tar
# cd mpfr-2.4.2
# ./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2/
# make
# make install

3. Install mpc-0.8.1 (requires gmp-4.3.2 and mpfr-2.4.2 as prerequisites )
# tar -zxvf mpc-0.8.1.tar.gz
# cd mpc-0.8.1
#./configure --prefix=/usr/local/mpc-0.8.1/ --with-gmp=/usr/local/gmp-4.3.2/ --with-mpfr=/usr/local/mpfr-2.4.2
# make
# make install

4. Update your LD_LIBRARY_PATH at your ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1:/usr/local/mpfr-2.4.2/lib:/usr/local/gmp-4.3.2/lib

5. Install the glibc-devel.i686. For more information, do look at Error when compiling GCC 4.8.1 (linuxtoolkit.blogspot.com) 6. Finally install GNU CC 4.7.2
# tar -zxvf  gcc-4.7.2.tar.gz
# cd gcc-4.7.2
# mkdir build-gcc
# cd build-gcc
# ../configure --prefix=/usr/local/gcc-4.7.2 \ 
--with-mpfr=/usr/local/mpfr-2.4.2 \ 
--with-mpc=/usr/local/mpc-0.8.1 \
--with-gmp=/usr/local/gmp-4.3.2 \
--with-mpfr-include=/usr/local/mpfr-2.4.2/include \
--with-mpc-include=/usr/local/mpc-0.8.1/include
# make all-gcc
# make install-gcc
# make -j 8
# make -j 8 install

Tuesday, September 17, 2013

Installing GNU 4.4 of C, C++ and gfortran for CentOS 5

Something I forget the package names of these essential compilers for  CentOS 5

# yum install gcc44 gcc44-c++ gcc44-gfortran

That's all..... One of the shortest blog entry

Monday, July 15, 2013

Compiling GNU 4.8.1 on CentOS 6

I encountered error when compiling GCC 4.8.1 on CentOS 6 I have the prequistics (via yum installed)
  1. gmp 4.3.1-7.el6_2.2
  2. mpfr 2.4.1-6.el6
  3. mpc 0.19-1.el6.rf
But still I enountered the error
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+. 
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations.  
Source code for these libraries can be found at their respective hosting sites as well as 
at ftp://gcc.gnu.org/pub/gcc/infrastructure/
To resolve the issue, download from the ftp://gcc.gnu.org/pub/gcc/infrastructure/ the following application and compile them.
  1. gmp-4.3.2.tar.bz2
  2. mpfr-2.4.2.tar.bz2
  3. mpc-0.8.1.tar.gz
1. Install gmp-4.3.2
# bunzip2 gmp-4.3.2.tar.bz2
# tar -zxvf gmp-4.3.2.tar
# cd gmp-4.3.2
# ./configure --prefix=/usr/local/gmp-4.3.2
# make
# make install

2. Install mpfr-2.4.2 (requires gmp-4.3.2 as prerequisites)
# bunzip2 mpfr-2.4.2.tar.bz2
# tar -zxvf mpfr-2.4.2.tar
# cd mpfr-2.4.2
# ./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2/
# make
# make install

3. Install mpc-0.8.1 (requires gmp-4.3.2 and mpfr-2.4.2 as prerequisites )
# tar -zxvf mpc-0.8.1.tar.gz
# cd mpc-0.8.1
#./configure --prefix=/usr/local/mpc-0.8.1/ --with-gmp=/usr/local/gmp-4.3.2/ --with-mpfr=/usr/local/mpfr-2.4.2
# make
# make install

4. Update your LD_LIBRARY_PATH reflect /usr/local/mpc-0.8.1/lib In your .bash_profile include the following
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1

5. Install the glibc-devel.i686. For more information, do look at Error when compiling GCC 4.8.1 (linuxtoolkit.blogspot.com)

6. Finally install GNU CC 4.8.1
# tar -zxvf  gcc-4.8.1.tar.gz
# cd gcc-4.8.1
# mkdir build-gcc
# cd build-gcc
# ../configure --prefix=/usr/local/gcc-4.8.1 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2
# make
# make install

Tuesday, July 9, 2013

Error when compiling GCC 4.8.1

For more information on installing GNU. See Blog Entry Compiling GNU 4.8.1 on CentOS 6.

During compilation, I encounter this error,
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: 
No such file or directory compilation terminated. make: *** Error 1

This is due to a missing 32-bits libraries during GNU compilation. Do a yum install
# yum install glibc-devel.i686

Wednesday, April 6, 2011

Compiling ScaLAPACK

ScaLAPACK is a library of high-performance linear algebra routines for distributed-memory message-passing MIMD computers and networks of workstations supporting PVM [68] and/or MPI [64, 110]
There are 2 ways you can compile ScaLAPACK, you can download scalapack.tgz and manually compile. Do look at the excellent article ScaLAPACK, LAPACK, BLACS and ATLAS on OpenMPI Linux installation tutorial

One challenges you might face is that if scaLAPACK dependencies are compiled with different Fortran compilers, you will face quite a challenge to complete the compilation.

Alternatively you can use the scalapack installer from http://www.netlib.org/scalapack/. 
Do look at the README to see the flags you will need.

Thursday, March 31, 2011

/usr/bin/ld cannot find -lf2c for CentOS 5

If you encounter this error "/usr/bin/ld: cannot find -lf2c", you are obviously missing f2c package. Do download the f2c-20031026-3.0.1.el5.x86_64.rpm package found at  f2c-20031026-3.0.1.el5.x86_64.rpm - CentOS 5 (RHEL 5) - ATrpms

# wget http://dl.atrpms.net/el5-x86_64/atrpms/stable/f2c-20031026-3.0.1.el5.x86_64.rpm
# rpm -Uvh f2c-20031026-3.0.1.el5.x86_64.rpm
# ldconfig

Wednesday, March 30, 2011

Compiling MPI BLACS on CentOS 5

An interesting article from Linux Cluster on Compiling MPI BLACS on CentOS 5. BLACS is compiled with OpenMPI 1.4.x with g77 and gfortran.

For more information see Compiling BLACS on CentOS 5

Compiling LAPACK on CentOS 5

Download the lapack latest stable version (lapack-3.3.0.tgz) from http://www.netlib.org/lapack/
# cd /root
# tar -xzvf lapack-3.3.0.tgz
# cd /root/lapack-3.3.0
# cp make.inc.example make.inc
Assuming Edit make.inc. Assuming the Compiling ATLAS on CentOS 5
#BLASLIB = ../../blas$(PLAT).a
BLASLIB = /usr/local/atlas/lib/libf77blas.a /usr/local/atlas/lib/libatlas.a
Compile lapack package
# make
Copy the libraries to
# mkdir /usr/local/lapack/lib
# cp /root/lapack-3.3.0/*.a /usr/local/lapack/lib
# cd /usr/local/lapack/lib/
# chmod 555 *.a
Other related Information
  1. Compiling ATLAS on CentOS 5

Tuesday, March 29, 2011

Compiling ATLAS on CentOS 5

This tutorial is to help you compile ATLAS (Automatically Tuned Linear Algebra Software) with gFortran. For those who are using Intel Compiler, you have the reliable Intel MKL (Math Kernel Library)

First thing first, some comparison between ATLAS and MKL.

ATLAS
ATLAS The Automatically Tuned Linear Algebra Software (ATLAS) provides a complete implementation of the BLAS API 3 and a subset of LAPACK 3. A big number of instructions-set specific optimizations are used throughout the library to achieve peak-performance on a wide variety of HW-platforms.

ATLAS provides both C and Fortran interfaces.

ATLAS is available for all HW-platforms capable of running UNIX or UNIX-like operating systems as well as Windows (tm).
MKL
Intel's Math Kernel Library (MKL) implements a set of linear algebra, fast Fourier transforms and vector math functions. It includes LAPACK 3, BLAS 3 and extended BLAS and provides both C and Fortran interfaces.

MKL is available for Windows (tm) and Linux (x86/i686 and above) only.
Download the latest stable package from ATLAS (http://sourceforge.net/projects/math-atlas/files/Stable/). The current stable version is atlas3.8.0.tar.gz. Do note that ATLAS don't like configuration on its original location, hence the need to create ATLAS_BUILD directory.
# cd /root
# tar -xzvf atlas3.8.3.tar.gz
# mkdir /root/ATLAS_BUILD
# cd /root/ATLAS_BUILD
# /root/ATLAS/configure
You will need to turn off CPU Throttling. For CentOS and Fedora, you will use
# /usr/bin/cpufreq-selector -g performance
For more information, you can see my blog entry Switching off CPU Throttling on CentOS or Fedora

Compile ATLAS
make
make check
make ptcheck
make time
make install
By default, ATLAS installed to /usr/local/atlas

Finally remember to add /usr/local/atlas/lib to your LD_LIBRARY_PATH

Tuesday, March 22, 2011

How to fix -fPIC errors

A very good article on fPIC error. See 3. HOWTO fix -fPIC errors by Gentoo Linux

If you have problem like " relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC .libs/assert.o: could not read symbols: Bad value ".

The article lists 4 cases of fPIC

Case 1: Broken Compiler
At least GCC 3.4 is known to have a broken implementation of the -fvisibility-inlines-hidden flag. The use of this flag is therefore highly discouraged, reported bugs are usually marked as RESOLVED INVALID. See bug 108872 for an example of a typical error message caused by this flag."
Case 2: Broken `-fPIC' support checks in configure
Many configure tools check whether the compiler supports the -fPIC flag or not. They do so by compiling a minimalistic program with the -fPIC flag and checking stderr. If the compiler prints *any* warnings, it is assumed that the -fPIC flag is not supported by the compiler and is therefore abandoned. Unfortunately, if the user specifies a non-existing flag (i.e. C++-only flags in CFLAGS or flags introduced by newer versions of GCC but unknown to older ones), GCC prints a warning too, resulting in borkage.

To prevent this kind of breakage, the AMD64 profiles use a bashrc that filters out invalid flags in C[XX]FLAGS. 

Case 3: Lack of `-fPIC' flag in the software to be built
This is the most common case. It is a real bug in the build system and should be fixed in the ebuild, preferably with a patch that is sent upstream. Assuming the error message looks like this:


Code Listing 6.1: A sample error message
.libs/assert.o: relocation R_X86_64_32 against `a local symbol' can not be used
when making a shared object; recompile with -fPIC .libs/assert.o: could not
read symbols: Bad value

This means that the file assert.o was not compiled with the -fPIC flag, which it should. When you fix this kind of error, make sure only objects that are used in shared libraries are compiled with -fPIC.
In this case, globally adding -fPIC to C[XX]FLAGS resolves the issue, although this practice is discouraged because the executables end up being PIC-enabled, too.

 Case 4: Linking dynamically against static archives
Sometimes a package tries to build shared libraries using statically built archives which are not PIC-enabled. There are two main reasons why this happens:
Often it is the result of mixing USE=static and USE=-static. If a library package can be built statically by setting USE=static, it usually doesn't create a .so file but only a .a archive. However, when GCC is given the -l flag to link to said (dynamic or static) library, it falls back to the static archive when it can't find a shared lib. In this case, the preferred solution is to build the static library using the -fPIC flag too.

Sometimes it is also the case that a library isn't intended to be a shared library at all, e.g. because it makes heavy usage of global variables. In this case the solution is to turn the to-be-built shared library into a static one.

    Saturday, September 25, 2010

    Installing GNU Compilers for CentOS 4.x

    If you are installing GNU compilers from yum for CentOS 4.x, here is the yum command to achieve it

    GNU Compilers for 3.x (C, C++, Fortran 77, Java)
    # yum install gcc, gcc-c++, gcc-g77, gcc-java

    GNU Compilers for 4.x (C, C++, Fortran 77, Java)
    # yum install gcc4, gcc4-c++, gcc4-gfortran, gcc4-java
    Or
    #yum install gcc4*