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

How to link BLAS lib--beginner question

CO_Traut
Beginner
347 Views
Hi, folks

I wrote a simple test code to learn how to link kml lib Mac (Mac OS X 10.5.7). The function I want to call is 'dgetrf'. But error message tells me lib files can not be found. Is that because of my path setting?

Thx much.

The command link is :

ifort myprog.f -L$MKLPATH -I$MKLINCLUDE

$MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_sequential.a

$MKLPATH/libmkl_core.a $MKLPATH/libmkl_intel_lp64.a

$MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a -lpthread


Error msg is :

ifort: error #10236: File not found: '/libmkl_core.a'

ifort: error #10236: File not found: '/libmkl_intel_lp64.a'

ifort: error #10236: File not found: '/libmkl_sequential.a'

ifort: error #10236: File not found: '/libmkl_core.a'

Undefined symbols:

"_dgetrf_", referenced from:

_MAIN__ in iforttH1bZs.o

ld: symbol(s) not found


My environment filemklvarsem64t.sh is:

#! /bin/sh

export MKLROOT="/opt/intel/Compiler/11.1/058/Frameworks/mkl"

if [ -z "${INCLUDE}" ]
then
export INCLUDE="${MKLROOT}/Headers"
else
export INCLUDE="${MKLROOT}/Headers:$INCLUDE"
fi

if [ -z "${DYLD_LIBRARY_PATH}" ]
then
export DYLD_LIBRARY_PATH="${MKLROOT}/lib/em64t"
else
export DYLD_LIBRARY_PATH="${MKLROOT}/lib/em64t:$DYLD_LIBRARY_PATH"
fi

if [ -z "${MANPATH}" ]
then
export MANPATH="${MKLROOT}/man/en_US:$(manpath)"
else
export MANPATH="${MKLROOT}/man/en_US:$MANPATH"
fi

if [ -z "${LIBRARY_PATH}" ]
then
export LIBRARY_PATH="${MKLROOT}/lib/em64t"
else
export LIBRARY_PATH="${MKLROOT}/lib/em64t:$LIBRARY_PATH"
fi

if [ -z "${CPATH}" ]
then
export CPATH="${MKLROOT}/include"
else
export CPATH="${MKLROOT}/include:$CPATH"
fi

if [ -z "${FPATH}" ]
then
export FPATH="${MKLROOT}/include"
else
export FPATH="${MKLROOT}/include:$FPATH"
fi

0 Kudos
5 Replies
Yuan_C_Intel
Employee
347 Views
Quoting - CO_Traut
Hi, folks

I wrote a simple test code to learn how to link kml lib Mac (Mac OS X 10.5.7). The function I want to call is 'dgetrf'. But error message tells me lib files can not be found. Is that because of my path setting?

Thx much.

The command link is :

ifort myprog.f -L$MKLPATH -I$MKLINCLUDE

$MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_sequential.a

$MKLPATH/libmkl_core.a $MKLPATH/libmkl_intel_lp64.a

$MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a -lpthread


Error msg is :

ifort: error #10236: File not found: '/libmkl_core.a'

ifort: error #10236: File not found: '/libmkl_intel_lp64.a'

ifort: error #10236: File not found: '/libmkl_sequential.a'

ifort: error #10236: File not found: '/libmkl_core.a'

Undefined symbols:

"_dgetrf_", referenced from:

_MAIN__ in iforttH1bZs.o

ld: symbol(s) not found


My environment filemklvarsem64t.sh is:

#! /bin/sh

export MKLROOT="/opt/intel/Compiler/11.1/058/Frameworks/mkl"

if [ -z "${INCLUDE}" ]
then
export INCLUDE="${MKLROOT}/Headers"
else
export INCLUDE="${MKLROOT}/Headers:$INCLUDE"
fi

if [ -z "${DYLD_LIBRARY_PATH}" ]
then
export DYLD_LIBRARY_PATH="${MKLROOT}/lib/em64t"
else
export DYLD_LIBRARY_PATH="${MKLROOT}/lib/em64t:$DYLD_LIBRARY_PATH"
fi

if [ -z "${MANPATH}" ]
then
export MANPATH="${MKLROOT}/man/en_US:$(manpath)"
else
export MANPATH="${MKLROOT}/man/en_US:$MANPATH"
fi

if [ -z "${LIBRARY_PATH}" ]
then
export LIBRARY_PATH="${MKLROOT}/lib/em64t"
else
export LIBRARY_PATH="${MKLROOT}/lib/em64t:$LIBRARY_PATH"
fi

if [ -z "${CPATH}" ]
then
export CPATH="${MKLROOT}/include"
else
export CPATH="${MKLROOT}/include:$CPATH"
fi

if [ -z "${FPATH}" ]
then
export FPATH="${MKLROOT}/include"
else
export FPATH="${MKLROOT}/include:$FPATH"
fi


Hi,
Seems you do not set your $MKLPATH environment variable from your script file, so that the actual option passing to compiler is /libmkl... which cannot be recognized.

0 Kudos
eliosh
Beginner
347 Views

Hi,
Seems you do not set your $MKLPATH environment variable from your script file, so that the actual option passing to compiler is /libmkl... which cannot be recognized.

MKL's scripts (mklvarsem64t.sh etc.) set neither $MKLPATH nor $MKLINCLUDE variables. Nevertheless, the user guide uses them extensively in numerous examples. In my view, this approach is misleading. Especially for new users.


0 Kudos
Steven_L_Intel1
Employee
347 Views
I'm going to move this thread to the MKL forum.
0 Kudos
CO_Traut
Beginner
347 Views
Quoting - eliosh
MKL's scripts (mklvarsem64t.sh etc.) set neither $MKLPATH nor $MKLINCLUDE variables. Nevertheless, the user guide uses them extensively in numerous examples. In my view, this approach is misleading. Especially for new users.


Yes, when I read through the userguild.pdf, I found $MKLPATH and $MKLINCLUDE are used quite often. However, I did not find the corresponding defination inmklvarsem64t.sh andmklvars.sh.Now my question is how to use the environment variables set in the two files to use MKL lib.
0 Kudos
Ying_H_Intel
Employee
347 Views

Hi,

Right, you can define them by enter command
export MKLINLCUDE="/opt/intel/Compiler/11.1/058/Frameworks/mkl/Headers"
export MKLPATH="/opt/intel/Compiler/11.1/058/Frameworks/mkl/lib/em64t"
or
replace the $MKLINCLUDE and $MKLPATH by${MKLROOT}/INCLUDE and ${MKLROOT}/lib/em64t in command line.

Just for your information:
MKL provide some example codes under "examples" directory, you can test it.
for example,
>cd /opt/intel/Compiler/11.1/046/Frameworks/mkl/examples/lapack (i'm using compiler 11.1.046 version)
>make libem64t function=dgetrf
make dgetrfx.res EXT=a _IA=em64t PLATF=em64t RES_EXT=lib
mkdir -p ./_results/intel_lp64_parallel_em64t_lib
ifort -w source/dgetrfx.f "/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t"/libmkl_intel_lp64.a "/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t"/libmkl_intel_thread.a "/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t"/libmkl_core.a "/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t"/libmkl_intel_thread.a "/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t"/libmkl_core.a "/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t"/libmkl_intel_thread.a "/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t"/libmkl_core.a -L"/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t" -liomp5 lib/libaux_em64t_intel.a -lpthread -o _results/intel_lp64_parallel_em64t_lib/dgetrfx.out
and run it
> export
DYLD_LIBRARY_PATH="/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t":/opt/intel/Compiler/11.1/046/lib:/opt/intel/Compiler/11.1/046/lib/intel64:/opt/intel/Compiler/11.1/046/Frameworks/mkl/lib/em64t; _results/intel_lp64_parallel_em64t_lib/dgetrfx.out DGETRF Example Program Results

Details of factorization
1 2 3 4
1 5.2500 -2.9500 -0.9500 -3.8000
2 0.3429 3.8914 2.3757 0.4129
3 0.3010 -0.4631 -1.5139 0.2948
4 -0.2114 -0.3299 0.0047 0.1314

IPIV
2 2 3 4


Regards,
Ying

0 Kudos
Reply