0

I compiled a copy of codes on one PC by Intel Fortran with the Lapack library. And then I ran it on another PC (the same OS without having Lapack installed). It failed.

This can be solved by installing Lapack on the other PC. The same problem occurs when using other libraries. This looks like a dynamical compiling issue (I am not sure). My question is how to get a real executable file that can be run on any machine?

hengyue li
  • 448
  • 3
  • 17
  • 1
    Did you look into the manual and look for word "static"? Did you try the `-static` flag? Did you try encounter any problems? Which compiler do you even have? It is different for different compilers. – Vladimir F Героям слава Nov 06 '17 at 07:34
  • i use ifort. I add "-static", after which it says " ld: cannot find -lm ,ld: cannot find -lc ,ld: cannot find -ldl, ld: cannot find -lc ". What that means? – hengyue li Nov 06 '17 at 11:03

1 Answers1

0

I get a quite clear answer now. The direct answer to the question is (as @Vladimir F mentioned & @Ross) use option "-static" for both gfortran and ifort.

Some possibly occurred problems.

The libs for static compiling and dynamical compiling are different. For instance, we may have installed a lib called "LIBNAME" already. However, a similar lib called "LIBNAME-static" may be needed for the "-static" option version. According to the warning of something like:

/usr/bin/ld: cannot find -lLIBNAME

what we need to installed is libLIBNAME. We can install it (Fedora for instance) by

sudo dnf install libLIBNAME.

And

sudo dnf install libLIBNAME-static

may also needed. Just try them.

hengyue li
  • 448
  • 3
  • 17
  • 1
    This answer is not useful. "To compile statically, use the `-static` flag". Your other problems were only mentioned in passing in a comment. – Ross Nov 06 '17 at 16:01