Cernlib 98 for RedHat 5.0
Brookhaven National Laboratory
Physics Department
Cernlib 98 has been built on an Intel platform running the RedHat 5.0 distribution of Linux. Two compiler sets were used, the cygnus gnu (egcs) compiler set version 1.0.2 and the Portland Group f77 compiler version 1.7.

Building Notes:

I have built cernlib 98 twice, once using the egcs 1.0.2 compiler set and once using the pgf77 1.7 fortran compiler. I have uploaded the .tar.gz files to asisftp where the cernlib management team should make them available to the wider physics community.

Glibc issues

When running glibc built executables on a non glibc linux distribution (i.e. libc version 5), you will get an error message similar to this. 'pawX11: file not found' This is a misleading message which really means that it cannot find some system files needed to load and execute pawX11, not that pawX11 executable is missing. I'm not sure what happens if you try and link to libraries built on a glibc platform on a non glibc platform. I haven't tried this, but my guess is that its inadvisable. The basic warning I'm trying to get across is that, if you are running RedHat 5.0, or the glibc version of debian, then this build should work ok for you, otherwise you should use the one provided by the CERN cernlib team on asisftp.

As for porting cernlib to redhat 5.0, there was only one major problem. This has to do with the redefinition of sys_errlist[]. A minor problem is the usage of getline() which is now defined in /usr/include/stdio.h. The fix for that was to comment it out in /usr/include/stdio.h. The redhat 5.0 patch file for the cernlib source can be found here.

There is a fairly large package called SHIFT which has many references to sys_errlist[]. This package comes bundled as a .tar file so a simple patch file will not patch it, so I've crated a separate redhat 5.0 SHIFT patch file which can be found here. You need to untar the SHIFT package before you can apply the patch file. You can find a redhat 5.0 patched version of the SHIFT tar file here.

egcs 1.0.2

I noticed that the g77 build of cernlib only used the minimal optimizing flags, -O, so I turned on a more aggressive set of optimization flag for this build of cernlib 98. I used -O2 -m486 -funroll-loops -fomit-frame-pointer. I have a simple bench marking program which indicates that these optimizing flags do a good job in maxing out the performance of the compiler. If you know of a better set or an optimization flag I left out, please let me know. The one 'danger' of the flags I used is the '-m486' which renders the build useless for a 386 machine, but I'm not going to worry about that.

pgf77 1.7

The optimization flags I used are '-O2 -Munroll -Mnoframe -tp p5' which are similar to the flags I used in the g77 build. In my previous build of cernlib for linux, I included a separate build using the Pentium Pro instruction set to try and gain some performance, but this gain is marginal (about 5%) which is not high enough for me to spend time and disk space on a PPro specific build. I did use the 586 (Pentium) instruction set flag (-tp p5 ) so this build may not work on a 486 machine. If someone does succeed in running this version of pawX11 on a 486 machine, I would like to know.


Lapack was missing from my previous release and is now included in both the g77 and pgf77 builds. I used the same fortran optimization flags as I did with the rest of the cernlib package.

Motif (Dynamically linked only...)

I used the RedHat motif 2.0.1 to build paw++. The only problem I had was that some initially unresolved functions were located in libXaw3d.a. This required me to modify the cernlib script which picks up all the libraries you need to build a cernlib executables. I don't believe I've modified this script properly, (hard wired '-lXaw3d' in the default Motif definition) but it works.  I found out today that the g77 version of paw++ dynamically links to the
Motif shared libraries. Maybe lesstif can handle it? If someone knows how to get lesstif to pickup the Motif calls, let me know. Or if someone knows how to force a statically liked version of paw++, also let me know and I'll try and make one.

Geant random number generator bug

Someone reported to me a problem with the geant random number generator in geant321/gtrack/grndm.F. A check of the source code indicates that this problem has been fixed by the CERN cernlib team.

Getting the cernlib source and building it

I used the following commands to retrieve the source from asisftp, and built it.

To fetch a copy of the cernlib source I did:

   cd cernlib/share/98
   get src.tar.gz
   mv src.tar.gz cernlib.98.src.tar.gz

Once I got my .src.tar.gz tarball, I did the following to untar, patch  and build it.

   mkdir /cern/work.98/
   cd /cern/work.98
   mkdir g77
   ln -s g77 new
   ln -s g77 pro
   cd new
   mkdir bin lib
   tar zxvf /where.ever/cernlib.98.src.tar.gz
   cd src
   patch -p0 < /where.ever/patch.cernlib.rh50
   cd packlib/kernlib/shift
   mv shift.tar shift.tar.orig
   cp /where.ever/shift.RH50.tar .
   ln -s shift.RH50.tar shift.tar
   cd /cern/work.98
   source setcernenv.g77
   /where.ever/build.all.g77 > build.all.g77.log 2>&1 &
   tail -f build.all.g77.log

If you want to build the pgf77 version of cernlib, then use this setcernenv.pgf77 script to setup your environment variables and this build.all.pgf77 script to do the build.

Last updated 4/19/1998