<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Shared library linked with MKL library fails to load MKL libs in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Shared-library-linked-with-MKL-library-fails-to-load-MKL-libs/m-p/1156363#M27608</link>
    <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;I'm building a shared library (VST 2.x plugin) on Linux that will be loaded using dlopen() call. I have an own test loader that loads and executes library commands without problems (dlopen(shared_library,RTLD_NOW|RTLD_GLOBAL)).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;When I start a DAW program (Renoise Tracker) it loads the shared library without problems but when it tries to execute commands in the shared library / VST 2.x plugin I get the following error message: "&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em;"&gt;Intel MKL FATAL ERROR: Cannot load libmkl_mc3.so or libmkl_def.so."&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;I tried to start renoise with LD_PRELOAD=&lt;/SPAN&gt;/opt/intel/compilers_and_libraries_2017.0.098/linux/mkl/lib/intel64_lin/libmkl_def.so as suggested in some forums but I get an error: "symbol lookup error: /opt/intel/compilers_and_libraries_2017.0.098/linux/mkl/lib/intel64_lin/libmkl_def.so: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8".&lt;/P&gt;

&lt;P&gt;I link MKL shared libraries with the following command-line switches:&amp;nbsp;-Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl. And the LD_LIBRARY_PATH is set as follows:&amp;nbsp;LD_LIBRARY_PATH=/opt/intel/compilers_and_libraries_2017.0.098/linux/compiler/lib/intel64:/opt/intel/compilers_and_libraries_2017.0.098/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2017.0.098/linux/tbb/lib/intel64/gcc4.4:/opt/intel/compilers_and_libraries_2017.0.098/linux/compiler/lib/intel64:/opt/intel/compilers_and_libraries_2017.0.098/linux/mkl/lib/intel64&lt;/P&gt;

&lt;P&gt;Do someone know how to fix this? I've compiled many programs with MKL and they work fine. I think Renoise either uses some special parameters when using dlopen() or sets environment so that libraries cannot be found and/or MKL tries to load some other libraries than normally. Maybe I should link shared library with some other MKL libraries too?&lt;/P&gt;

&lt;P&gt;Other libraries in normal locations like /usr/lib seem to load and work without any problems.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 19:39:52 GMT</pubDate>
    <dc:creator>rpls</dc:creator>
    <dc:date>2018-03-19T19:39:52Z</dc:date>
    <item>
      <title>Shared library linked with MKL library fails to load MKL libs</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Shared-library-linked-with-MKL-library-fails-to-load-MKL-libs/m-p/1156363#M27608</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;I'm building a shared library (VST 2.x plugin) on Linux that will be loaded using dlopen() call. I have an own test loader that loads and executes library commands without problems (dlopen(shared_library,RTLD_NOW|RTLD_GLOBAL)).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;When I start a DAW program (Renoise Tracker) it loads the shared library without problems but when it tries to execute commands in the shared library / VST 2.x plugin I get the following error message: "&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em;"&gt;Intel MKL FATAL ERROR: Cannot load libmkl_mc3.so or libmkl_def.so."&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;I tried to start renoise with LD_PRELOAD=&lt;/SPAN&gt;/opt/intel/compilers_and_libraries_2017.0.098/linux/mkl/lib/intel64_lin/libmkl_def.so as suggested in some forums but I get an error: "symbol lookup error: /opt/intel/compilers_and_libraries_2017.0.098/linux/mkl/lib/intel64_lin/libmkl_def.so: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8".&lt;/P&gt;

&lt;P&gt;I link MKL shared libraries with the following command-line switches:&amp;nbsp;-Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl. And the LD_LIBRARY_PATH is set as follows:&amp;nbsp;LD_LIBRARY_PATH=/opt/intel/compilers_and_libraries_2017.0.098/linux/compiler/lib/intel64:/opt/intel/compilers_and_libraries_2017.0.098/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2017.0.098/linux/tbb/lib/intel64/gcc4.4:/opt/intel/compilers_and_libraries_2017.0.098/linux/compiler/lib/intel64:/opt/intel/compilers_and_libraries_2017.0.098/linux/mkl/lib/intel64&lt;/P&gt;

&lt;P&gt;Do someone know how to fix this? I've compiled many programs with MKL and they work fine. I think Renoise either uses some special parameters when using dlopen() or sets environment so that libraries cannot be found and/or MKL tries to load some other libraries than normally. Maybe I should link shared library with some other MKL libraries too?&lt;/P&gt;

&lt;P&gt;Other libraries in normal locations like /usr/lib seem to load and work without any problems.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 19:39:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Shared-library-linked-with-MKL-library-fails-to-load-MKL-libs/m-p/1156363#M27608</guid>
      <dc:creator>rpls</dc:creator>
      <dc:date>2018-03-19T19:39:52Z</dc:date>
    </item>
    <item>
      <title>Hi Tomas,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Shared-library-linked-with-MKL-library-fails-to-load-MKL-libs/m-p/1156364#M27609</link>
      <description>&lt;P&gt;Hi Tomas,&lt;/P&gt;

&lt;P&gt;May you pelase&amp;nbsp;&amp;nbsp;try to link&amp;nbsp; as the &amp;nbsp;&lt;A href="https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/"&gt;https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;1. &amp;nbsp;using static mkl like &amp;nbsp;-Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_gnu_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lgomp -lpthread -lm -ldl&lt;/P&gt;

&lt;P&gt;2. or&lt;/P&gt;

&lt;P&gt;&amp;nbsp;-lmkl_rt&amp;nbsp;&amp;nbsp;-lpthread -lm -ldl&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;to replace the library &amp;nbsp;&amp;nbsp;-Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp&lt;/P&gt;

&lt;P&gt;and see if it work?&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 01:21:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Shared-library-linked-with-MKL-library-fails-to-load-MKL-libs/m-p/1156364#M27609</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2018-03-20T01:21:22Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Shared-library-linked-with-MKL-library-fails-to-load-MKL-libs/m-p/1156365#M27610</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I just ran into the same issue as well and was able to debug the problem using LD_DEBUG=all. I have a shared library that is being dlopen'd and contains a dependency to MKL. My shared library is linked with libmkl_core.so, libmkl_sequential.so, and libmkl_intel_lp64.so.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;When the MKL function is called, the mkl_core library is dispatching to libmkl_avx.so and libmkl_def.so and proceeding to dlopen these files. However, the scope of the MKL dispatch library is my executable's library list and the MKL dispatch library's list. My executable doesn't contain the MKL libraries since it is a dependency of the library I originally dlopen'd and the dispatch libraries don't contain the main MKL files in its library list so it ends up getting a fatal error and crashes the program&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I think there are 3 options for me to handle this now which are not ideal...&lt;BR /&gt;
	-&amp;nbsp;&lt;SPAN style="font-size: 1em;"&gt;I've been able to get it working is by doing an LD_PRELOAD containing all of the main MKL libraries I need (mkl_core.so, mkl_sequential.so, mkl_intel_lp64.so) when starting the executable. But this is not ideal because then the libraries are being loaded even if the library using MKL isn't used.&lt;BR /&gt;
	- Dynamically link the shared objects into the executable. But this adds MKL dependencies on the executable when they may not be needed&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN style="font-size: 1em;"&gt;- S&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em;"&gt;tatically link these dispatch libraries into the library with the MKL dependency but then that would also defeat the purpose of using the shared libraries by increasing the library size with unused symbols&lt;BR /&gt;
	- Build a custom MKL shared object containing all of the functions needed. Requires knowing what functions will be called now and in the future&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Let me know if you need some more information or a test program to show the problem&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 23:14:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Shared-library-linked-with-MKL-library-fails-to-load-MKL-libs/m-p/1156365#M27610</guid>
      <dc:creator>Anonymous92</dc:creator>
      <dc:date>2018-03-22T23:14:52Z</dc:date>
    </item>
  </channel>
</rss>

