GreenGroup/RMG-Java — Issue #224: Compiling RMG-Java in Ubuntu 11.10
Author: jwallen
Created: 2011-11-01 14:46:02+00:00
State: open

Anyone running the most recent stable release of Ubuntu/Kubuntu/etc., 11.10 (Oneiric), will suddenly find that most of the Fortran modules no longer compile successfully. Actually, the compilation step is generally the same as before, but the linker step fails with errors like:

```
gfortran -lpthread -lblas -llapack /files/RMG-Java/build/fame/math.o /files/RMG-Java/build/fame/states.o /files/RMG-Java/build/fame/_modes.o /files/RMG-Java/build/fame/network.o /files/RMG-Java/build/fame/io.o /files/RMG-Java/build/fame/mastereqn.o /files/RMG-Java/build/fame/msc.o /files/RMG-Java/build/fame/rs.o /files/RMG-Java/build/fame/model.o /files/RMG-Java/build/fame/fame.o -o /files/RMG-Java/bin/fame.exe
/files/RMG-Java/build/fame/network.o: In function `__networkmodule_MOD_reaction_fitreversekinetics':
/files/RMG-Java/source/fame/network.f90:806: undefined reference to `dgels_'
/files/RMG-Java/build/fame/msc.o: In function `estimateratecoefficients_msc_':
/files/RMG-Java/source/fame/msc.f90:179: undefined reference to `dgesv_'
/files/RMG-Java/build/fame/rs.o: In function `activestatebanded_':
/files/RMG-Java/source/fame/rs.f90:549: undefined reference to `dgbsv_'
/files/RMG-Java/build/fame/rs.o: In function `activestatefull_':
/files/RMG-Java/source/fame/rs.f90:383: undefined reference to `dgesv_'
/files/RMG-Java/build/fame/model.o: In function `__modelmodule_MOD_fitpdeparrheniusmodel':
/files/RMG-Java/source/fame/model.f90:174: undefined reference to `dgels_'
/files/RMG-Java/build/fame/model.o: In function `__modelmodule_MOD_fitchebyshevmodel':
/files/RMG-Java/source/fame/model.f90:102: undefined reference to `dgels_'
collect2: ld returned 1 exit status
make[1]: *** [/files/RMG-Java/bin/fame.exe] Error 1
make[1]: Leaving directory `/files/RMG-Java/source/fame'
make: *** [fame] Error 2
```

However, you can see that BLAS and LAPACK are clearly requested to be linked to the compiled executable. This definitely affects FAME and GATPFit, and perhaps DASSL/DASPK as well.

It turns out that Ubuntu -- and Debian, the upstream distro that Ubuntu is based on -- have quietly turned on a few new flags in the linker utility. The result is that the order of the command-line options to the linker is now extremely important, where before it did not matter. For example, the linker will now (silently!) drop any shared libraries that aren't needed by the files that precede them on the command line; this means that these should generally be the last arguments of the linker.

Here's something I found talking about the change:

http://wiki.debian.org/ToolChain/DSOLinking

I am working on updating our Makefiles accordingly.