2

I recently followed the instruction on this thread for compiling BLAS and LAPACK as pre-requisites to a SciPy installation. First I got a gfortran error at some point, which recommended that I re-compile LAPACK with -fPIC. So I did this by replacing the -frecursive with -fPIC in makefile.inc (which, I assume is some file the Makefile reads for different compile options) and the error was gone.

Can someone explain more generally what the difference is in compiling something with -fPIC and -frecursive, and how it helped fix the error in my case.

Thanks!

Community
  • 1
  • 1
user1953384
  • 1,049
  • 2
  • 15
  • 29
  • On searching further, I found an answer [here](http://stackoverflow.com/questions/19364969/relocation-r-x86-64-32-against-rodata-str1-8) – user1953384 May 17 '14 at 13:25
  • 2
    .. Except -frecursive has nothing to do with -fPIC -- reading the fort ran compiler man page, you most likely need both. – Soren Nov 21 '14 at 00:57

1 Answers1

3

As Soren already commented: -fPIC is totally unrelated to -frecursive. PIC influences how machine code can be positioned inside memory. If you want to compile a library code must be compiled to be relocatable. In other words the code must be able to run regardless of where it is loaded in memory. This question deals with this in more detail.

The -frecursive indeed should be specified if possible. Older implementations of gfortran, e.g. gfortran 4.1.2 on RedHat 5 do not support this option. Currently I haven't seen a workaround, so you have to remove it. The gfortran documentation describes it as

Allow indirect recursion by forcing all local arrays to be allocated on the stack

In the thread you mentioned, for compilation of the LAPACK library the option -frecursive can be removed. Then the library compiles.

If it works without this feature remains to be seen. Haven't tested yet.

Community
  • 1
  • 1
cfi
  • 10,915
  • 8
  • 57
  • 103