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

Help: basic MKL link options using Intel C compiler under Linux

MikeP_Intel
Moderator
488 Views
I'm very new to MKL and I'm trying to get a very basic C program (using MKL)to compile and link under Linux (Redhat RHEL 4 Update 7) - see attached

But try as I have I can't get it to link (see makefile below) - already run mklvars32.sh - this should be easy.


------------------------START MAKEFILE--------------------------------
CC = icc

XLD_LIBRARY_PATH="/opt/intel/mkl/10.0.011/lib/32"

XMKLINC=-I"/opt/intel/mkl/10.0.011/include"
MKLLIB=/opt/intel/mkl/10.0.011/lib/32/libmkl_intel.a \
/opt/intel/mkl/10.0.011/lib/32/libmkl_core.a


matrix: mkl_lab_solution.c
$(CC) mkl_lab_solution.c -I$(INCLUDE) -L$(MKLLIB)

clean:
rm *.o matrix

---------------------END MAKEFILE-----------------------------

So what do I need to include in the makefile to get this simple C program to compile and use MKL?



output from make:
icc mkl_lab_solution.c -I/opt/intel/mkl/10.0.011/include -L/opt/intel/mkl/10.0.011/lib/32/libmkl_intel.a /opt/intel/mkl/10.0.011/lib/32/libmkl_core.a
/tmp/icc7nJbz4.o(.text+0x49b): In function `main':
: undefined reference to `cblas_ddot'
/tmp/icc7nJbz4.o(.text+0x7b7): In function `main':
: undefined reference to `cblas_dgemv'
/tmp/icc7nJbz4.o(.text+0x9fb): In function `main':
: undefined reference to `cblas_dgemm'
/tmp/icc7nJbz4.o(.text+0xcb9): In function `Dgemm_multiply':
: undefined reference to `cblas_dgemm'
/tmp/icc7nJbz4.o(.text+0xd40): In function `Dgemv_multiply':
: undefined reference to `cblas_dgemv'
/tmp/icc7nJbz4.o(.text+0xde9): In function `Ddot_Multiply':
: undefined reference to `cblas_ddot'
make: *** [matrix] Error 1


0 Kudos
1 Solution
Gennady_F_Intel
Moderator
488 Views
Quoting - jaewonj
The best way may be to open the MKl userguide for Linux and refer to page 49 ~ 50 (5-7 ~ 5-8).



agree with jaewonj's advice: this is really the best way. You can find there Syntax of Linkig command and a lot of examples for IA32 and intel64 architectures.
The second way - visit the Linker Adviser KB article: "http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/".

--Gennady

View solution in original post

0 Kudos
2 Replies
jaewonj
Novice
488 Views
The best way may be to open the MKl userguide for Linux and refer to page 49 ~ 50 (5-7 ~ 5-8).


0 Kudos
Gennady_F_Intel
Moderator
489 Views
Quoting - jaewonj
The best way may be to open the MKl userguide for Linux and refer to page 49 ~ 50 (5-7 ~ 5-8).



agree with jaewonj's advice: this is really the best way. You can find there Syntax of Linkig command and a lot of examples for IA32 and intel64 architectures.
The second way - visit the Linker Adviser KB article: "http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/".

--Gennady
0 Kudos
Reply