46

I am seeking help for installation in ubuntu 14.04. I am installing a package in my pc. They have their makefiles. I have to run make.

When I did I found error like.....

gfortran -O2 -fopenmp -msse2 -o nmbnd.run p_nmbnd.o i_main.o m_getwsr.o ../IOLIB/*.o ../ATOM/*.o ../BNDASA/*.o ../EXTENS/*.o ../FINDES/*.o ../LATTICE/*.o ../SAMPLE/*.o ../TETRA/*.o ../IOCTRL/*.o ../LMIO/*.o ../MAINA/*.o ../NMTO/*.o ../SYM/*.o ../TBSTR/*.o ../CHAPOT/*.o  -L/usr/share/doc/liblapack -llapack -L/usr/share/doc/libblas -lblas 
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
make[2]: *** [nmbnd.run] Error 1
make[2]: Leaving directory `/home/santuphys/NMTO-47.ZB.28/06.gfort/MAIN'
make[1]: *** [cleanmake] Error 2
make[1]: Leaving directory `/home/santuphys/NMTO-47.ZB.28/06.gfort/MAIN'
make: *** [ooo.dep] Error 2

I tried all the other similar questions in this forum about link, but I could not resolve it. I specified the path to Lapack and Lblas in my pc also writing...

LAPACK_LIB=   -L/usr/lib/ -llapack  -lblas

It did not work. Please help me with this issue.

Thanks in advance.

Bowdzone
  • 3,827
  • 11
  • 39
  • 52
Leostorm10
  • 457
  • 1
  • 4
  • 5

3 Answers3

80

On Ubuntu, make sure you have the packages

  • liblapack-dev
  • libopenblas-dev

installed:

sudo apt install liblapack-dev libopenblas-dev

After that, "-L/usr/lib -llapack -lblas" should work. Also note that, as already mentioned in another answer, in the output you showed, you have "-L/usr/share/doc/liblacpack -L/usr/share/doc/libblas", which is certainly not what you want.

slhck
  • 36,575
  • 28
  • 148
  • 201
janneb
  • 36,249
  • 2
  • 81
  • 97
  • 26
    ubuntu one-liner for the lazy `sudo apt-get install liblapack-dev -y ; sudo apt-get install liblapack3 -y ; sudo apt-get install libopenblas-base -y ; sudo apt-get install libopenblas-dev -y ;` – J-Dizzle Aug 08 '16 at 17:51
  • 1
    time saver! you may need to run apt-get update before or apt-get -f install after if runing into issues. – Qiang Li Apr 25 '18 at 19:46
  • 7
    `sudo apt install liblapack-dev libopenblas-dev` is enough for 16.04 – prusswan Jul 13 '18 at 05:21
  • This was only a partial solution in my case (trying to compile an R package, that is "qwraps2"). I succeeded after applying also the solution proposed below, the one regarding the missing symbolic link to libgfortran.so – Will Mar 25 '21 at 14:07
2

Just install packages that contain liblapack.so.* and libblas.so.* libraries. If you are sure that those packages are already installed - just find them by: find / -name 'liblapack*' and add that path to gcc with -L/path/to/liblapack.

edit: In your invocation of fortran compiler there are some directories given with -L - but are you sure that needed libraries are located in documentation directories: -L/usr/share/doc/liblapack -L/usr/share/doc/libblas ?

user2699113
  • 4,262
  • 3
  • 25
  • 43
1

My error was like this:

/usr/bin/ld: cannot find -lgfortran

I solved the problem following this post in here

sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/4.9/libgfortran.so /usr/lib/libgfortran.so

N.B. I know this is an old post. But I spent a lot of time to solve this and in the end, it was very simple. I hope others having the same problem can solve this very quickly.

user3503711
  • 1,623
  • 1
  • 21
  • 32
  • In addition, to get the location of your library, you can use "locate gfortran.so" – user3503711 Jul 09 '19 at 19:41
  • Very helpful, not only I needed to install libgfortran-5-dev (Ubuntu 18.04) but indeed the above symbolic link was necessary to the compilation work. – Will Mar 25 '21 at 14:10