简体   繁体   中英

Why does intel compiler produce output that requires libiomp5mt.dll, even though I ask for static linking?

I'm compiling an openmp project with the /MT switch (or equivalently in visual studio settings, "C++: Code Generation: Runtime Library: Multi Threaded".

Visual Studio still, however, reports that my output requires libiomp5mt.dll (multi threading dll) when I thought the above setting was asking for static linking.

Is there another option somewhere I missed?

Alternatively, if the dll is a requirement, I presume I'm allowed to redistribute Intel's dll alongside my own application?

The above switch is for C++ runtime only, OpenMP is an external library which is not a part of the C++ runtime. Hence the switch doesn't have any effect on it.

As per the redistribution of the DLL, look at the license of the product the DLL was shipped with. You're probably allowed to redistribute it.

The Intel website says:

You are strongly encouraged to dynamically link in the compatibility OpenMP* run-time library libiomp (ie libiomp5md.lib and libiomp5md.dll , located in the [Compiler Dir]\\lib directory), even if other libraries are linked statically. Linking to static OpenMP* run-time library (ie libiomp5mt.lib) is not recommended. Because multiple OpenMP libraries in one appliation causes performance problems (too many threads) and may cause correctness problems if more than one copy is initialized.

So although you can configure OpenMP to link statically, and this configuration is independent of the C runtime, you are recommended not to.

Intel's OpenMP licence allows for royalty free redistribution as far as I can tell. You should check the licence that came with your OpenMP just to be on the safe side.

There are two ways of creating code libraries. As static Libs and as Dlls (Extentsions: *.lib and * dll).

If there is only a Dll available, you can only link to it dynamically, not statically. What may be confusing you is that a Dll usually has a lib file you link to which has all the entry points into the Dll.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM