Question

Okay, I have the source code for a large open-source program on a Linux HPC. There are two distinct systems that make up the HPC, arc1 and arc2, which share a filesystem. Essentially, I need two separately compiled versions of this program, as the two systems have different libraries and compiler versions etc. However, I would like to be able to compile both of these versions from the same source code.

The problem I am having is that once I have compiled the code once with a particular compiler, it seems to become "locked" to that particular compiler. When I try to subsequently re-compile with a different compiler, even on the same system, it gives me many errors of the form:

[file.o]:[line]: undefined reference to '_gfortran_****'

where **** is a number of different built-in Fortran functions. I have to admit I know very little about how compilers actually work, so I am at a loss to explain this.

So, my query boils down to two main questions:

1) Is there any quick fix for the "undefined reference" errors between gfortran versions? The code was initially compiled on arc1 with gfortran 4.1.2 and I am trying to compile it on arc2 with gfortran 4.4.7.

2) If not, is there any way to "unlock" the code so that I can re-compile it on both systems with ifort instead (as both systems have the same version of ifort installed)? At the moment when I try to compile it with ifort on either system it throws up thousands of the "undefined reference" errors.

Was it helpful?

Solution

Sum of the comments. The linker clearly receives object file named file.o that was compiled by gfortran and doesn't know where to find the symbols from the gfortran run-time libraries. The build script didn't recompile this file with the new compiler.

The solution is to use the facility of the particular build system, e.g. make clean, to delete all files produced by the previous build.

I note there may be problem also with the .mod files that some build scripts tend to ignore.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top