Reputation: 51
Environment : Linux, Ubuntu 16.04
I tried to download MKL Library from intel website (https://software.intel.com/content/www/us/en/develop/tools/math-kernel-library.html), and try to link mkl to my program.
(I just downloaded l_mkl_2020.1.217.tar
file, extracted it, and ran ./install.sh
inside that file)
But every time I tried to build, below message was printed
$ pkg-config --cflags --libs mkl-dynamic-lp64-iomp.pc
Variable 'MKLROOT' not defined in 'mkl-dynamic-lp64-iomp.pc
Even if I tried export MKLROOT=/opt/intel/mkl
(which is my mkl root path),
It still couldn't find MKLROOT
path
I also tried run test.sh file like below,
echo $MKLROOT
and It clearly print MKLROOT
variable out.
are variable in intel .pc file is somewhat different from environment variable on Ubuntu? and why my mkl couldn't reach out to MKLROOT
variable?
If anyone can answer this, I'll truly appreciate for you. Thanks!
--- addition ---
I just resolved this issue by adding single line
MKLROOT=/opt/intel/mkl
at the very first part of mkl-dynamic-lp64-iomp.pc
(even though its readonly file, I just typed wq!
), but I think its not a radical solution. Still need answer and any help would be appreciated
Upvotes: 5
Views: 8011
Reputation: 749
It seems that the pkg-config
metadata file does not work with external environment variables, even if you properly exported them.
But pkg-config
has another mechanism for this. You can set PKG_CONFIG_MKL_DYNAMIC_LP64_IOMP_MKLROOT
:
$ echo $MKLROOT
/opt/intel/compilers_and_libraries_2020.4.304/linux/mkl
$ pkg-config --cflags mkl-dynamic-lp64-iomp
Variable 'MKLROOT' not defined in '/opt/intel/compilers_and_libraries_2020.4.304/linux/mkl/bin/pkgconfig/mkl-dynamic-lp64-iomp.pc'
$ export PKG_CONFIG_MKL_DYNAMIC_LP64_IOMP_MKLROOT=$MKLROOT
$ pkg-config --cflags mkl-dynamic-lp64-iomp
-I/opt/intel/compilers_and_libraries_2020.4.304/linux/mkl/include
In general, the environment variable PKG_CONFIG_XXX_VVV
will override the variable VVV
in the package XXX
. Both XXX
and VVV
must be in upper case, and with non-alphanumeric characters converted to underscores. (See man pkg-config
)
(Note that your package is imkl-dynamic-lp64-iomp
, without the .pc
extension.)
Upvotes: 2
Reputation: 236
There should be a script called mklvars.sh
under the <mkl_install_dir>/mkl/bin/
directory that sets all the necessary environment variables (like MKLROOT) for you. (I believe you will need to do this each time you want to use MKL, or you can add this to your ./bashrc
file so it gets sourced each time you open your shell.)
With regard to setting the pkg-config files, here are the instructions from the Intel documentation:
To adjust compilation and link options in the pkg-config metadata file:
- Go to the <mkl_install_dir>/mkl/bin/pkgconfig directory.
- Specify the ${prefix} variable, which contains the full path to the Intel MKL directory that could be changed if another path to MKL is needed.
- Specify Libs:the link line that is returned by pkg_config --libs. You can get the preferred link line for the Intel MKL configuration using the Intel MKL Link Line Advisor or the offline Intel MKL link line tool. In the link line returned by the advisor, be sure that you change the external environment variable ${MKLROOT} to the internal pkg-config ${prefix}, since the pkg-config metadata file will not work with the external environment variable. However you can set it outside with the pkg-config tool (see the pkg-config tool man page for more information).
- Specify Cflags: the compiler options that will be returned by pkg-config --cflags. You can also update it (see the instruction from step 3).
The Intel MKL Link Line Advisor is available here.
In my case, it sufficed to do steps 1 and 2; the link lines and include directories are correct. You might need to change this if you plan to use MKL with the GNU compilers.
Upvotes: 0
Reputation: 581
I am not sure I understand the problem. To set the proper environment variable, you have to call script ( mklvars.sh) to set this environment variable. E.x.source mklvars.sh ia32/intel64 or source compilervars.sh ia32/intel64 in the case if you use an intel compiler.
Upvotes: 0