Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
6743 Discussions

Having trouble referencing/creating MKL.DLL in Visual C# Studio


I am having a terrible time setting up Intel's Math Kernel for Visual C#. I have downloaded and ran the install file with no luck of accessing the Math Kernel Functions inside of the mkl.dll file. When I implement one of mkl.dll functions a BadImageFormatException is thrown. Online documentations instructs you to go through the visual studio command prompt and call:

    "mklvars.bat" ia32
    nmake ia32

When I run this throught the shell mklvars.bat ia32 is accepted and nmake ia32 throws and it throws an error within  the command prompt.

I tried using the MKL_Link_Tool.exe with the following result and still receive the bad image exception:


    class Program
        static class MKL
            [DllImport("mkl.dll", CallingConvention = CallingConvention.Cdecl)]
                internal static extern int DftiCreateDescriptor(ref IntPtr desc,
            int precision, int domain, int dimention, int length);
        static void Main(string[] args)
            IntPtr pnt = new IntPtr(32);
                Console.Write(MKL.DftiCreateDescriptor(ref pnt, 1, 1, 10, 10) + "");
            catch (BadImageFormatException ex)

I can't figure out how to use Intel's Math Kernel Library with Visual Studio... Can anyone help me set up MKL (escpicially the BLAS and LA packages) Thank you.

0 Kudos
2 Replies
Black Belt

Assuming that you have downloaded and extracted the three zip files at, before running "nmake ia32" on a 64-bit system you have to set the environment variable CSCOPTS=/platform:x86 (to receive this information, run the command nmake help).

To do the same from Visual Studio, from the IFort command window run devenv, and create a new C# console project, add the C# source code to the project, select the configuration and build.

Note that the examples are all set up to run, output results to the console and quit, so you may want to put a breakpoint at the last source line of Main before running each program. 


Hi Michael,

If possible, could you please use dependency walker to detect if all dlls are founded. as the article described

In order to avoid the dynamic library environment check, you may first to try mkl_intel_c.lib mkl_sequential.lib mkl_core.lib. which is static library and sequential library. then try other configuration.

Best Regards,