Error in linking gfortran to LAPACK and BLAS
Give this a try
gfortran randomsys1.f90 -L/usr/lib -llapack -L/usr/lib -lblas
I think you went one directory too far
I wrote a program using the LAPACK eigensolver and here is how I successfully compiled it on my own computer. It was used to calculate modes of a spring-mass system.
gfortran eigen.f90 -L/usr/local/lib -lblas -L/usr/local/lib -llapack
This also works on my computer
gfortran eigen.f90 -lblas -llapack
I just tried both to verify.
PS, now that you know how to compile, I think you need the subroutine init_random_seed in your program (goes after "contains" but before "end program"). This one is from google. No idea if it is what you need, your professor should be able to steer you correctly here.
! Initialize the random number generator using current time,
! so a new sequence of random numbers is generated each
! execution time.
! Taken from http://gcc.gnu.org/onlinedocs/gfortran/RANDOM_005fSEED.html
SUBROUTINE init_random_seed()
INTEGER :: i, n, clock
INTEGER, DIMENSION(:), ALLOCATABLE :: seed
CALL RANDOM_SEED(size = n)
ALLOCATE(seed(n))
CALL SYSTEM_CLOCK(COUNT=clock)
seed = clock + 37 * (/ (i - 1, i = 1, n) /)
CALL RANDOM_SEED(PUT = seed)
print *, "Using random seed = ", seed
print *, " "
DEALLOCATE(seed)
END SUBROUTINE
LAPACKE C++ linking error. Unable to find function
I am compiling with:
g++ -lblas -llapack -llapacke -I /usr/include main.cpp
That command line is wrong. Do this instead:
g++ main.cpp -llapacke -llapack -lblas
To understand why the order of sources and libraries matters, read this.
Problems in linking LAPACK with Code:Blocks GNU fortran compiler Ubuntu 14.04
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.
Linking error with LAPACK under cygwin
Supposing that you have installed BLAS
and LAPACK
libraries correctly and the system can locate them, then you just have to change the order in the compile command.
$ g++ main.cpp -llapack -lblas
The compiler should know which functions of main.cpp
should look into the libraries before declare them.
Related Topics
In Bash Tee Is Making Function Variables Local, How to Escape This
Sending Realtime Signal from a Kernel Module to User Space Fails
Hugo Version Not Updating to Latest
Interpreting Openssl Speed Output for Rsa with Multi Option
How to Use Multiple Lower Layers in Overlayfs
Linux Slab Allocator and Cache Performance
How to Generate Files in a Docker Container for Having The Same Owner as The Host's User
What Is The Side Effect of Setting Tcp_Max_Tw_Buckets to a Very Small Value
How Does Iwlist() Command Scans The Wireless Networks
Create and Test X86-64 Elf Executable Shellcode on a Linux Machine
Whole-System Snapshot on Operating System
How to Rename a Kernel Module Name Without Renaming The .Ko Passed to Insmod
Gatttool: Limited to 5 Connections
Get Canonical Path from Pathname
Avoid Copying of Data Between User and Kernel Space and Vice-Versa
Producer Consumer Implementation in a Block Device Driver
"Relocation R_X86_64_32S Against '.Bss' Can Not Be Used When Making a Shared Object"