1
votes

I want to link LAPACK library with my fortran code (.f90) on Ubuntu 14.04

I run this with terminal option gfortran -o main main.f95 -L"usr/lib/lapack" -llapack and it compiles with no error. But in Code::Blocks, I create a fortran project and goto Project->Build options

enter image description here

And it gives error when I build the project gfortran error: usr/lib/lapack/liblapack.so No such file or directory

I do not understand what is going wrong. I also have LAPACK installed. These are files at /usr/lib/lapack liblapack.a liblapack.so liblapack.so.3 liblapack.so.3.0 Any help?

2
Open the log file and show what exactly the IDE does behind the scenes.Vladimir F
Is there any possibility that the setting in the "Search Directories" tab is not happy with this IDE?roygvib

2 Answers

1
votes

Where it says "Link libraries", where you currently have /usr/lib/lapack/liblapack.so, you enter just lapack and blas.

Where it says "Other linker options:", and you have -llapack and -lblas, you leave it empty. If that fails, you might add -L"usr/lib/lapack" there, but you probably don't need to.

If you look at the "Build log" tab at the bottom, it should tell you amongst other things the gfortran command that it has executed.

1
votes

Your problem is strange; I would expect the command line one to cause problem:

gfortran -o main main.f95 -L"usr/lib/lapack" -llapack

You should have "/" at the beginning of the path name unless there is local tree in your porject defined as usr/lib/lapack. It can still work if some environments variables allow you to always have the location of libraries.

When it comes to your development environment (that I do not use) you do not need to add the full path to the library and the options -llapack together. You add -llapack when you provide only the path.