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

Linking a Multithread Library into a Multithread DLL Application

schulzey
New Contributor I
389 Views

I am compiling a Fortran library (let's call it library A) that references some MKL functions and I have it set up as "Multithreaded" so that the MKL functions are statically linked and I don't have to ship MKL DLLs with my application.

In one case I am linking library A into an application that uses some MKL functions (via library A) and so I have also set up the application as "Multithreaded". It works fine.

In another case I am linking library A into a different application that doesn't use any MKL functions and so I have set up that application as "Multithread DLL". The reason I have set up the second application as "Multithread DLL" is because I don't want it to statically link in a whole host of other runtime libraries that it references. Is this allowed or am I asking for trouble by doing this?

0 Kudos
3 Replies
Steve_Lionel
Honored Contributor III
389 Views

The best thing when building a Fortran library is to set the option to disable library OBJCOMMENT directives so that the choice of library type is done by the executable application when it is linked. In Visual Studio, this is Fortran > Libraries > DIsable OBJCOMMENT directives... > Yes.

Note that you don't have this freedom in C/C++, as that compiler generates different code depending on the run-time library type setting, but Intel Fortran does not.

Note that this does mean that the executable needs to explicitly link to the appropriate Fortran support libraries. If the main program is in Fortran, that happens automatically.

0 Kudos
schulzey
New Contributor I
389 Views

So if I disable library OBJCOMMENT directives in library A, does the Multithreaded vs Multithreaded DLL setting matter when I'm compiling that library?

0 Kudos
Steve_Lionel
Honored Contributor III
389 Views

No, it does not matter - the setting then has no effect.

0 Kudos
Reply