mismatch detected for 'vccorlib_lib_should_be_

2019-08-10 19:28发布

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.

2条回答
祖国的老花朵
2楼-- · 2019-08-10 20:17

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
查看更多
干净又极端
3楼-- · 2019-08-10 20:19

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'
查看更多
登录 后发表回答