As I discussed in a previous question, I am trying to run a python script that uses f2py wrapped Fortran code on a remote server. If I compile the f2py module locally on my own pc and then run the script on the server, I get the following error,
ImportError: liblapack.so.3: cannot open shared object file: No such file or directory
This is logical since lapack and blas are both not installed on the remote server, and sadly I do not have the root privileges to install them. I am wondering if I could fix this by using static linking. On the GNU wiki it is stated that,
One way to avoid this (more ideas can be found on the binaries page) is to use the so-called "static linking", available with option
-static
. Gfortran then puts the library code inside the program created, thus enabling it to run without the library present (like, on a computer where gfortran is not installed).
This sounds like exactly what I would need. If the required library files are included in the f2py module then I won't need the lapack and blas modules on the remote server and I can just run it as is. However I am not sure that this static linking actually works with f2py. Currently I run,
python -m numpy.f2py -llapack -lblas -c --fcompiler=gnu95 --compiler=unix signature_file.pyf
object_files.o
object_files.o
means all interdependent Fortran files compiled into object files, i.e. I ran
gfortran -c -llapack -lblas object_file.F90
on all relevant files. Now I would like to do this with static linking, but how? I have tried adding -static when compiling the object files, but this didn't change anything. I have also tried adding -static to the f2py call, but this just gives an unknown option error.