[Ipopt] IPOpt windows binaries runtime libs: /MT /MTd /MD /MDd

Vallon, Justin Justin.Vallon at deshaw.com
Thu Sep 23 12:32:01 EDT 2010

Chuck, Damien,

My understanding of mixing static and dynamic runtime libraries is that it can cause problems.  Unfortunately, many statements just end there.  KB Q140584 is more specific about problems when crossing CRT libs: Two separate heaps, cannot pass FILE*, locales setting is not shared.

If Ipopt is being shipped/blessed as a static CRT, then all heap operations should already be at arms-length: Don't use new IpoptApplication(), but instead use IpoptApplicationFactory(), etc.

That is, if the caller is a static CRT, and the DLL (Ipopt) is also a static CRT, then the API needs to be careful to insure that the DLL heap (etc) are well-isolated from the caller.  Therefore, it should not matter whether the caller is dynamic or static since the DLL keeps itself isolated.  Any problem with dynamic/static setups would also be a static/static problem.

Chuck:  Could you/we use /MTd in future builds?  I am new to the list.  Are the binaries built using the SVN vcproj files?  I can look into making the change there.


On Wed Sep 22 17:47:45 EDT 2010, Teeter, Chuck wrote:

Sorry for the confusion on the VS2008 General Notes.  I should have use '/MTd' rather than '/MD' for the static debug version of Ipopt.  My main point was to avoid the mixing of release and debug runtimes as Damien mentions below.

From: ipopt-bounces at list.coin-or.org [mailto:ipopt-bounces at list.coin-or.org] On Behalf Of Damien
Sent: Wednesday, September 22, 2010 3:20 PM
To: ipopt at list.coin-or.org
Subject: Re: [Ipopt] IPOpt windows binaries runtime libs: /MT /MTd /MD /MDd


/MD means link for the C/C++ release, runtime dlls (msvc... dlls etc).  /MDd means link for the C/C++ debug, runtime dll (msvc...d dlls).  /MT means link the C/C++ release, runtime static library (libc.... libs etc).  /MTd means link the C/C++ debug, runtime static library (libc...d libs).

If the notes say release is /MT and debug is /MD, that's linking static release libraries on a release build, and dynamic release dlls on a debug build.  That's a bit unusual, and won't always work well on a debug build, depending on how exceptions or errors are handled.

It's generally not a good idea to mix debug and release runtimes, and sometimes you can get weird link errors mixing static lib and dll runtimes, so use only /MT or only /MD everywhere for release, and only /MTd or only /MDd everywhere for debug.  You can't control what third parties do with their code though.  I generally do /MD or /MDd for the runtimes, because the dll is only loaded once, no matter how many times it's linked to from anyone's library.


On 21/09/2010 9:56 AM, Vallon, Justin wrote:
The wiki https://projects.coin-or.org/Ipopt/wiki/CompilationHints ... Windows VS2008 ... General Notes says that release binaries are built with /MT and debug are built with /MD.

For debug C++ code, shouldn't I be using /MDd or /MTd in my application?  Can I mix my /MTd or /MDd code with Ipopt /MD?

I looked at the win32/debug/Ipopt.dll, and I don't see a dependency on any VS DLLs.  Maybe debug is /MTd?



More information about the Ipopt mailing list