mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker': value '1' doesn't match value '0' in msvcrtd.lib

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 12:37:15

问题


I have a C library project for UWP. There are some C files which are calling C++ WINRT functions defined in CPP file.It is compiling successfully and generating a library file(LIB). I am compiling in Visual Studio 2015 with update 1 and target platform is 10.0.10240.0

But, I want to generate DLL instead of LIB file. Here's the changes I did to change the project so that it generates DLL instead of LIB.

Try1: So, In the startup project, In Configuration Properties => General I change Configuration from Static Library to Dynamic Library.

And in all the project, I changed from Multi-threaded Debug(/MTd) to Multi-threaded Debug DLL(/MDd).

Try2: Created a new project Windows Universal Project and added the all the files from the project creating LIB to this project. Still, I am getting the below errors.

Now, I am getting the errors

vccorlibd.lib(init.obj) : error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker': value '1' doesn't match value '0' in msvcrtd.lib(app_appinit.obj)
vccorlibd.lib(init.obj) : error LNK2005: __crtWinrtInitType already defined in msvcrtd.lib(app_appinit.obj)
msvcrtd.lib(initializers.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

Any Suggestions how to resolve this.


回答1:


I had the same Issue and fixed it using the linker flags:

/nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib

for debug builds you can use:

/nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib



回答2:


The standard /nodefaultlib did not work for me.

The following linker flags (for debug) did the trick in my case:

/defaultlib:'vccorlibd.lib' /defaultlib:'msvcrtd.lib'


来源:https://stackoverflow.com/questions/34939913/mismatch-detected-for-vccorlib-lib-should-be-specified-before-msvcrt-lib-to-lin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!