I would like to use LAPACK functions in my dynamic link library. In visual studio I set the project properties to link to the math kernel library. However when calling the Fortran subroutine from Java it seems that the LAPACK functions are not found and an error is issued:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'C:\Users\...\Documents\Visual Studio 2012\Projects\TEQ\TEQ\Debug\TEQ': The specified module could not be found.
All the subroutines in the Fortran module are exported using DLLEXPORT and I am able to call them in Java. However when one of the LAPACK subroutines is inserted the error is issued. I am not sure how to export the LAPACK subroutines? Do we need to export the routines or point to them in some way?
It is typical for interpreted languages to tell you that your own DLL couldn't be loaded when in fact the problem is a dependent DLL. The MKL DLLs are not added to PATH by default as of the 2013 product, so perhaps you need to add the folder with the MKL DLLs to PATH.
I am using the following link to setup the mkl libraries: https://software.intel.com/sites/default/files/article/184496/intel-mkl-configuring-in-microsoft-vis.... I also ran the file mklvars.bat ia32 to set enviornment variables. However I'm getting the following error when trying to build. Is there a more updated instructions to set up the MKL libraries? I appreciate your help.
Error 1 error #11018: Cannot open mkl_intel_ilp64.lib
Error 2 fatal error LNK1181: cannot open input file 'mkl_intel_ilp64.lib' LINK
Observe the occurrences of "64" in the error messages. Those 64-bit libraries should not have been required if you were compiling for X86, as your using the "ia32" argument to mklvars.bat. That they are asked for by the linker is an indication that one or more objects/libraries given to the linker were compiled for X64. Check the settings in your project and make sure that X64 is not specified anywhere, clean and rebuild all objects and targets (including user-built libraries and third-party libraries).
Mohammad K. wrote:
The 64 library is for using long int and not 64 arch. I also checked it applies to 32 bit system.
With few exceptions (Pardiso being one), there is no provision for calling MKL routines with 64-bit integer arguments from 32-bit code. Such calls would require at least two versions for each MKL routine that takes one or more integer arguments. Multiple library routines of this nature are not provided in 32-bit MKL. The ILP64 and LP64 MKL libraries contain 64-bit code segments, and they cannot be linked to 32-bit code.
By redefining preprocessor symbols such as MKL_INT, it it possible to deceive the compiler and make it behave as if code using 64-bit integers ought to work on the IA32 platform, but code compiled this way will always result in link time failures.
I set the path to the MKL libraries in the command prompt using mklvars.bat. I also set net beans to point the java library path to the MKL path
C:\Program Files\Intel\Composer XE 2013\mkl\lib\ia32
But the error of loading the library is not resolved. Any ideas?
I don't know anything about Netbeans. Did you start Java from the MKL command prompt? I was suggesting editing the system PATH using Computer > Properties > Advanced > Environment Variables.
I am not using the MKL command prompt to generate the library. I am using the Visual Studio 2012 that comes with Intel Fortran Composer. I was able to compile and link an application that calls the same program. It is the dynamic linking that is not working. Is there an Intel document that describes in detail what are the settings needed in Visual Studio in terms of libraries, include paths, etc to generate a DLL library which can be called from Java? Also I was able to do this for Fortran DLL that is not dependent on MKL, so that only settings are MKL libraries? I tried using the MKL link adviser and inserted all dependent libraries that are needed but still I'm getting an error that the module is not found. Thanks for your help.
It seems this path need to be set in the application running the Java code. I am using Netbeans to run my java application. Do you know how I can set the java library path to the MKL library path? I tried setting in the VM options under run in Netbeans
-Djava.library.path="C:\Program Files\Intel\Composer XE 2013\mkl\lib\ia32"
But this didn't work.