Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Problems with linking libraries


Dear all,

I'm using ifort composer_xe_2013_sp1.2.144 with Ubuntu 14.04.4

I want to install a program following the instruction given for other compilers and platforms.

I compiled the relevant source files and created a library libtrlan.a. with ar t I checked that all objects are included.

The I wanted to create a test program that uses the programs in libtrlan.a, which themselves need LAPACK and BLAS routines.

Problem 1:

Irrespective of whether I try to link the MKL libraries to the exe or not, none of the routines for which interfaces in a MOD file are given is found

ifort -o simple.exe  libtrlan.a  simple.o

yields    simple.f90:(.text+0x88): undefined reference to `trl_init_info_' etc.

If I change the order of the files

ifort -o simple.exe    simple.o libtrlan.a

there are undefined references to the BLAS routines that are not yet added.

Problem 2:

When I try to link the MKL libraries with

ifort  -o simple.exe -L/opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/  libmkl_lapack95_lp64.a  libmkl_blas95_lp64.a  simple.o  libtrlan.a

I get fortran errors

ifort: error #10236: File not found:  'libmkl_lapack95_lp64.a'
ifort: error #10236: File not found:  'libmkl_blas95_lp64.a'

When I do not use the -Ldir option

ifort  -o simple.exe /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_lapack95_lp64.a /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_blas95_lp64.a simple.o  libtrlan.a

I get again the undefined references to the BLAS routines.

I have no idea what's going wrong.

Please, help.



0 Kudos
2 Replies
Black Belt

At some point in time, you will need to learn how to use libraries to build programs.

Does your code (simple.f90, or the code used to build libtrlan.a) call MKL routines with the F95 interface? If not, it may suffice to issue the command

     ifort -mkl simple.o -L. -ltrlan  -o simple.exe

Otherwise, please use the MKL link advisor ( ).


0 Kudos

Hi Alex, 

Problem 1:

The cause should be the library's location,  Linux  linker only resolve the symbol in link line from start to end one time, so you may pay attention about the order of files, library .  For example,  put all libraries after the source code *. f90 or *.o 

Problem 2; 

You may try  to get right mkl library. 

for example 

ifort  -o simple.exe  simple.o  libtrlan.a  /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_lapack95_lp64.a /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_blas95_lp64.a  -Wl,--start-group /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_core.a /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_intel_thread.a  -Wl,--end-group -liomp5 -lpthread -lm -ldl

Best Regards,



0 Kudos