Thread: Combining /MD and /MT codes

  1. #1
    Registered User
    Join Date
    Nov 2005
    Location
    Canada
    Posts
    80

    Combining /MD and /MT codes

    I have a piece of code that can be compiled using the /MD keyword and another one that can be compiled only using the /MT keyword. Is there a way I could combine these two into one project, so that I can call the functions in both from each code?

    Thanks.

  2. #2
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    probably not. you'll almost certainly end up with multiply defined symbols in the link table.

    why can't you re-compile one or the other?
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  3. #3
    Registered User
    Join Date
    Nov 2005
    Location
    Canada
    Posts
    80
    That's bad news then... One is written using the .NET library (but in C++) and needs to be compiled using /clr (no support for /MT). The other one relies on a 3rd party API (Perforce -p4api) that must be compiled using /MT. I need to use the functions of the API in my .NET code, else a nearly 3-day effort is going into the trash can.

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    if the code compiled with Multithreaded DLL is dll itself - should not be a problem...
    Warnings about multiple definitions can be ignored in this case (i suppose) because both versions are release and multithreaded...

    I'm not sure that versions of the CRT used by the NET code and by the standard C++ are the same... So the conflicts there could make a problem...

    Have you tried to link these parts of the code?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Your third party API is compiled into a DLL?

    You may be able to just scrap the import library and explicitly load the library (LoadLibrary(), FreeLibrary(), GetProcAddress()) as it really shouldn't matter how the DLL is implemented if you're not using an import library.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed