LuaJIT lib built with / MD but doesn't cause runtime library mismatch with / MDd program?

I downloaded the luajit source from

http://luajit.org/git/luajit-2.0.git

and built it using msvcbuild.bat

https://github.com/luvit/luajit-2.0/blob/master/src/msvcbuild.bat

From the batch file, it uses / MD to create lua51.lib. When I linked the library to my application, I found that visual studio 2013 was not throwing a runtime library mismatch when I used / MDd settings for my application.

I also created another source in libraries using visual studio and I need to build two lib versions to avoid mismatch error.

My question is, is it possible to build a library that can be used both with a program compiled with settings / MD and / MDd ?

If so, is it safe to do so?

If the answer is no, why is there no error linking the lua51.lib application with / MDd?

Thank.

Edit

Error message

Error 20 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Logger.obj
+3


source to share


1 answer


Question 1:

Is it possible to create a library that can be used both with a program compiled with the / MD and / MDd settings?

Answer: Yes.

Question 2:

Is it safe to do this?



Short answer: Not always.

Longer answer:

When a flag is used /MD

, the compiler defines proprocessor macros _MT, _DLL

. When used /MDd

, the compiler defines proprocessor macros _MT, _DLL, _DEBUG

.

It is possible that one or more classes will have different member variables depending on whether or not _DEBUG

. In this case, it is most likely unsafe to mix codes compiled with different flags. If you are absolutely sure that none of the objects passed between two sets of code have this problem, it is probably safe to mix the two sets of code / libraries.

+4


source







All Articles