Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Linking against older runtime libraries

Manuel_S_1
Beginner
475 Views

Hello,

I am building a sparse linear solver library which we need to run inside Matlab R2015b. This means that at runtime the runtime libraries of Matlab will be the ones the dll loads. When I build the dll with MSVS2017 + Intel Parallel XE 2018 the fortran compiler defaults to link against the latest fortran and openmp libraries, this causes Matlab to crash at runtime. The runtimes that ship with Matlab R2015b are the Intel ones from 2013, so my solution to get it working was to build my library using Intel Composer XE 2013, but this forces me to use an older MSVS (I used 2010). Is there a way to use the current compiler (which I assume does some better optimisations than the 2013 one) and force it to link against older runtimes? I was not able to figure out a way to do this, and my current method does not seem to be the most elegant solution, not to mention that I have to rely on the MSVS 2010 runtimes (later versions would not allow compiler integration) to be available/supported for eternity.

I hope there is a better solution.

Thank you!

Manuel

0 Kudos
3 Replies
Steve_Lionel
Honored Contributor III
475 Views

Is there a way to force linking against older libraries? Yes. Will it work if you do this? Maybe, maybe not. Newer compilers may generate calls to routines not in the older libraries, may use interfaces not supported, or may take advantage of newer implementations. If you're seriously unlucky, you may not discover a problem for quite a while.

The general rule is to use the oldest compiler whose libraries you want to support.

Is the issue with the MSVC libraries and not the Intel libraries? What happens if you specify that your DLL links against the static libraries? (Other than libiomp5.)

0 Kudos
Manuel_S_1
Beginner
475 Views

Thank you for your response, Steve!

I assume you mean specifying /lib:static /threads in the additional compiler command line argument, as I cannot find a selection box for this in the linker pages. This unfortunately doesn't seem to solve it. In a previous attempt I had determined that it was actually directly related to the openmp runtime. Some of the symbols that are defined in current versions were not defined in the 2013 version, these were some aligned allocations and free functions. My workaround then was to replace the openmp runtime in matlab's biniary directory which works locally. But we cannot replace elementary components of matlab company-wide so the next best solution was the one I outlined before.  How can I force a more recent compiler to link against a specific version of e.g. libiomp5md.lib as it is in e.g. the Intel Composer XE 2013 directories?

Thank you,

Manuel

0 Kudos
Steve_Lionel
Honored Contributor III
476 Views

The project property you want is Fortran > Libraries  > Use Run-Time Libraries  > Multithread

Trying to pull in an older OpenMP runtime is perilous. You would, at a minimum, have to replace libiomp5md.dll in the appropriate subfolder(s) of C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist with the older one. But if you used OpenMP at all in your own code, that would be a big problem. In the case of DLLs, it's not the linking that's really the issue but which DLL Windows loads at run-time.

0 Kudos
Reply