0

I can compile a Fortran code using

gfortran -o $target *.o -lblas

But it does not compile with

gfortran -lblas -o $target *.o

Why does it depend on the position of the -lblas flag? Is it the standard behavior? If not, how can I troubleshoot?

The BLAS libraries are in a non-standard location and set in the LD_LIBRARY_PATH environment variables. Running gfortran v9.3.0 on Ubuntu 20.04.

Ian Bush
  • 6,996
  • 1
  • 21
  • 27
banskt
  • 416
  • 3
  • 7
  • 17
  • 1
    This is common for all languages in GCC, and most other compilers (and linkers) also. A library is only recognized as needed, and thus linked, if it it is looked at, which occurs in the order given on the commandline, _after_ the (or at least one) object module that references it. Although this practice is very common, there is no _de jure_ standard on this topic that I know of. – dave_thompson_085 Dec 02 '20 at 23:23
  • Thanks for the link to the other question. That was what I was looking for. – banskt Dec 03 '20 at 00:06

0 Answers0