0
votes

Does it link against the runtime library when i build my static lib? Does it "put" the code from runtime lib into my lib?

Or is it just information for linker, so that when it links final exe(dll) it knows what version of runtime library to use for this particular static library?

Do i need to use the same version of runtime library in all my static libs and dlls? Do i need to use the same type (/MT /MTd /MDd ...) in all my static libs and dlls?

And one more short question, is it usual that static windows libraries are twice the size of linux static libraries?

1
Quick test. Change the runtime library to something other than what it's set for now. Press "Build" (do not do a "Rebuild All"). Note that the entire library is rebuilt from scratch, compiling all the modules. Given all your questions, what does that indicate?PaulMcKenzie

1 Answers

1
votes

Or is it just information for linker, so that when it links final exe(dll) it knows what version of runtime library to use for this particular static library?

Yes.

Do i need to use the same version of runtime library in all my static libs and dlls?

I strongly strongly advise it. You will get a mess of linker errors if you don't.

Do i need to use the same type (/MT /MTd /MDd ...) in all my static libs and dlls?

Yes.

If you are releasing a DLL to be consumed by a 3rd-party, you may want to provide them with YourLibraryD.dll which uses the /MTd flag, and a YourLibrary.dll which uses /MT. Have different solution configurations for each. Nobody uses the single-threaded versions any longer, because the performance penalty is mostly irrelevant now and not worth the risk.

EDIT: Even if you aren't releasing to a 3rd party, you still want to make sure you link to the right DLL when in debug -vs- release mode. This is because when you build YourApp.exe in Debug, which uses /MTd, you will want it to link to YourLibraryD.dll. When you build YourApp.exe in Release, which uses /MT, you will want it to link to YourLibrary.dll in release mode. You could keep the DLL name the same and use the directory to disambiguate: so then you link to bin\debug\YourLibrary.dll in debug mode, and bin\release\YourLibrary.dll in release mode. Sorry if this is beyond your question, it is just good to know when you first switch build configurations and suddenly you start getting linker errors.