I have been trying to compile my fortran code, where I am using a couple of mkl functions such as dss solver, MKL_DCSRMULTCSR, MKL_DCSRGEMV, etc. Previously I had a similar code, from which I was compiling a dll. I was calling then the created dll from matlab using loadlibrary function. This has worked in the past, because my code did not use any of the mkl functions I mentioned above.
Now when I try the loadlibrary command, it complains that it does not recognize the mkl functions. I have been searching for solutions here in forum, on the web, etc. Unfortunately, all the things I have tried so far failed. This is where I need your help.
So far I have tried two approaches:
- I tried to link the mkl libraries while I am compiling the code. For example I have tried commands such as:
ifort -shared -fpic -o Engine.so -O3 -L/usr/local/intel/composer_xe_2013.5.192/mkl/lib/intel64/ -I/usr/local/intel/composer_xe_2013.5.192/mkl/include/ -lmkl_intel_lp64.so -lmkl_sequential -lmkl_core SourceCode/*.f90
Although it does not return any error and creates the Engine.so successfully, when I load it in matlab, it tells me that it cant find "lmkl_intel_lp64.so" library (even if I copy it to the same directory). My question here is: do you think there is something wrong the way I compile it or do I need to define something on matlab side?
- the second thing I tried was just to compile it without linking to mkl libraries as:
ifort -shared -fpic -o Engine.so -O3 SourceCode/*.f90
where included the "mkl_dss.f90" file in my fortran code. This again returns no error and created the dll successfully. And when I load it in matlab, it actually does NOT complain about dss functions (so I assume that I managed to include the dss solver). However it still complains about the remaining two MKL_DCSRMULTCSR, MKL_DCSRGEMV functions. I know that they are part of mkl_spblas however there is no .f90 file for this, but only an .fi file (I think the difference is still not clear to me, i.e. why there is f90 file for dss but an fi file for spblas). As a result, I could not do the same trick for these two functions.
Sorry for the long post, I tried to summarize it as short as possible while describing the important parts.
I would be glad for any suggestions how I could make this thing work
Thank you very much in advance,
I (and maybe others) answered previously that you must set the path for MKL shared objects at run time consistent with what you did at compile time (normally, by sourceing the mklvars script, which is done by the compilervars script). The custom shared object discussed in the reference would offer an alternative.
If you want the shared objects to work from your current directory, or the one where your application resides, you must add that to your LD_LIBRARY_PATH (if it's allowed by your site policies). linux adopted the policy of not putting current directory on path over a decade ago, hoping to avoid some of the simple trojan horse vulnerabilities.