Search code examples
linkerc++-climixed-mode

What libraries do I need to link my mixed-mode application to?


I'm integrating .NET support into our C++ application.
It's an old-school MFC application, with 1 extra file compiled with the "/clr" option that references a CWinFormsControl.

I'm not allowed to remove the linker flag "/NODEFAULTLIB".
(We have our own build management system, not Visual Studio's.)
This means I have to specify all necessary libraries: VC runtime and MFC.

Other compiler options include "/MD"

Next to that: I can't use the linker flag "/FORCE:MULTIPLE" and just add everything:
I'm looking for a non-overlapping set of libraries.


Solution

  • How I solved it:

    1. link with "/FORCE:MULTIPLE /verbose" (that links ok) and set the output aside.
    2. link with "/NODEFAULTIB /verbose" and trace all unresolveds in the output of the previous step and add the libraries 1 by 1.
    3. This resulted in doubles: "AAA.lib: XXX already defined in BBB.lib"
    4. Then I finally got it: Recompiled managed AND unmanaged units with /MD and link to (among others): mscoree.lib msvcmrt.lib mfcm80d.lib

    Mixing /MT (unmanaged) and /MD (managed) turned out to be the bad idea: different(overlapping) libraries are needed.

    @ajryan: Dependcy Walker only tells me what dll's are used, not what libraries are linked to when linking. (e.g. msvcmrt.lib ?) I think.

    Thanks for the answers!

    Jan