Linker error - mismatch between release and debug runtime libraries.

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
mattgill
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Mar 21, 2016 12:53 pm

Linker error - mismatch between release and debug runtime libraries.

Postby mattgill » Mon Mar 21, 2016 1:11 pm

Hello, I am using wxWidgets on Windows 8.1 with Visual Studio Community 2015.

First I compiled the default version of wxWidgets and managed to get the "minimal" sample to work. I then wanted to write my own application using the Hello World text as an example (from from http://docs.wxwidgets.org/trunk/overvie ... world.html). After a lot of playing around the only way I found that worked was to copy the samples\minimal folder and replace minimal.cpp with new file hello.cpp, which had the hello world sample code . I managed to get it to compile in debug mode.

I then wanted to try deploying this executable onto another Windows machine WITHOUT Visual Studio installed. I got the error that "MSVCP140D.dll" was missing. Ithink the problem was that I had to compile it as a static release executable, rather than as a static debug one.

So I cleaned out my wxWidgets build and then rebuilt the release version: nmake /f makefile.vc BUILD=release
This built OK.
Then I went back to Visual Studio and did a clean. I then changed the config to a release (not debug) executable (not DLL). But I get these link errors: "LNK2038 mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in hello.obj"

What am I doing wrong here? PS I have tried changing the Visual Studio config so it uses MFC as a static library rather than dynamic but that doesn't work.

Thanks.

User avatar
T-Rex
Moderator
Moderator
Posts: 1164
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Re: Linker error - mismatch between release and debug runtime libraries.

Postby T-Rex » Mon Mar 21, 2016 1:21 pm

You need to build the wxWidgets with static CRT. Maybe it would be easier for you to build via IDE, you just will need to select all wxWidgets library projects and set the static runtime in project settings -> C/C++ -> Code Generation section.

Then, after you get wxWidgets compiled with static CRT, you need to rebuild your app. And after that you will be able to move it to other PC without installing the C++ Redistributable package.

mattgill
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Mar 21, 2016 12:53 pm

Re: Linker error - mismatch between release and debug runtime libraries.

Postby mattgill » Mon Mar 21, 2016 2:32 pm

Thanks T-Rex.
Is there a command-line compile switch etc I could use?

mattgill
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Mar 21, 2016 12:53 pm

Re: Linker error - mismatch between release and debug runtime libraries.

Postby mattgill » Mon Mar 21, 2016 3:07 pm

Hi, I just rebuilt the wxWidgets projects listed under wx_vc14 solution. I made sure that Release|Win 32 was selected.

Then I cleaned out my hello world stuff and rebuilt it as Release|Win32 (I note that the "deploy" option was greyed out).

So I should be having everything built as Release|Win32. But I still get the same linker errors :(

User avatar
doublemax
Moderator
Moderator
Posts: 12672
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linker error - mismatch between release and debug runtime libraries.

Postby doublemax » Mon Mar 21, 2016 3:49 pm

In Visual Studio:
Project properties -> Configuration properties -> C/C++ -> Code Generation -> Runtime Library

For release with static runtimes select "multi-threaded (/MT)"

All libraries in your project must use the same CRT setting.
Use the source, Luke!

mattgill
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Mar 21, 2016 12:53 pm

Re: Linker error - mismatch between release and debug runtime libraries.

Postby mattgill » Mon Mar 21, 2016 4:28 pm

Thanks. I changed every one of the 20+ library projects which come with wx_vc14.proj. (BTW is there a quicker way than what I did - changing each one individually?)
Then I rebuilt, and did the same with my Hello World. But now I get a different linker problem:

unresolved external symbol _wWinMain@16 referenced in function "int __cdecl __scrt_common_main_seh(void)"

Am I using the incorrect settings when I build wxWidgets?

From propertyPages: typical C/C++ command line:
/MP /GS /analyze- /W3 /Zc:wchar_t /I"..\..\lib\vc_lib\mswu" /Zi /Gm- /O2 /Ob2 /Fd"..\..\lib\vc_lib\wxjpeg.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_LIB" /D "_CRT_SECURE_NO_DEPRECATE=1" /D "_CRT_NON_CONFORMING_SWPRINTFS=1" /D "_SCL_SECURE_NO_WARNINGS=1" /D "NDEBUG" /D "_CRT_SECURE_NO_WARNINGS" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /GF /WX- /Zc:forScope /GR /Gd /Oy- /Oi /MT /Fa"vc_mswu\wxjpeg\" /EHsc /nologo /Fo"vc_mswu\wxjpeg\" /Ot /Fp"vc_mswu\wxjpeg\wxjpeg.pch"

and typical Librarian command line:
/OUT:"..\..\lib\vc_lib\wxjpeg.lib" /MACHINE:X86 /NOLOGO

Please also see the screenshot to see if I have the wxWidgets library build configured correctly.

Thanks
Attachments
screenshot.PNG

User avatar
T-Rex
Moderator
Moderator
Posts: 1164
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Re: Linker error - mismatch between release and debug runtime libraries.

Postby T-Rex » Mon Mar 21, 2016 4:59 pm

http://screencast.com/t/GTu3UtIlW6Y
http://screencast.com/t/7bqvA0khlsW

Your app's settings should have the same configuration.

User avatar
doublemax
Moderator
Moderator
Posts: 12672
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linker error - mismatch between release and debug runtime libraries.

Postby doublemax » Mon Mar 21, 2016 7:07 pm

I changed every one of the 20+ library projects which come with wx_vc14.proj. (BTW is there a quicker way than what I did - changing each one individually?)
Yes, select them all first, then change the setting.

Besides that: Take the project files from the "minimal" sample and start from scratch. What you're doing should be simple, some settings must be screwed up somewhere.
Use the source, Luke!

mattgill
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Mar 21, 2016 12:53 pm

Re: Linker error - mismatch between release and debug runtime libraries.

Postby mattgill » Tue Mar 22, 2016 9:27 am

Hi. Thanks for the suggestions.

Unfortunately, on my version of Visual Studio (Community 2015 Update 1) there does not seem to be a nice way of selecting all the projects at once. I've had a good look and there are no checkboxes I can select or "select all" menu option. Maybe you just get that in the paid-for version.

All my projects, both wxWidgets core code and the minimal code, are set to be Release configuration with /MT switch, as per T-Rex's screenshot. Unfortunately, I get a linker error for "minimal": Error LNK1104 cannot open file 'wxtiffd.lib' minimal C:\wxWidgets-3.1.0\samples\minimal\LINK 1

This is the linker error I get on my Hello World sample (again with Release and /MT specified):

Error LNK2019 unresolved external symbol _wWinMain@16 referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ) hello C:\wxWidgets-3.1.0\samples\hello\LIBCMT.lib(exe_wwinmain.obj) 1

as before.

Are there some other settings?

Thanks.

User avatar
doublemax
Moderator
Moderator
Posts: 12672
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linker error - mismatch between release and debug runtime libraries.

Postby doublemax » Tue Mar 22, 2016 9:48 am

Unfortunately, on my version of Visual Studio (Community 2015 Update 1) there does not seem to be a nice way of selecting all the projects at once. I've had a good look and there are no checkboxes I can select or "select all" menu option.
Select them like in a file explorer: Select the first, hold SHIFT and click the last one.

both wxWidgets core code and the minimal code, are set to be Release configuration with /MT switch, as per T-Rex's screenshot. Unfortunately, I get a linker error for "minimal": Error LNK1104 cannot open file 'wxtiffd.lib' minimal C:\wxWidgets-3.1.0\samples\minimal\LINK 1
The "d" in "wxtiffd.lib" indicates the "debug" version. So there must be still a release/debug mismatch somewhere.
Use the source, Luke!

mattgill
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Mar 21, 2016 12:53 pm

Re: Linker error - mismatch between release and debug runtime libraries.

Postby mattgill » Tue Mar 22, 2016 10:50 am

Hello.

Good news! I managed to build both the minimal and HelloWorld apps in Release mode. I checked they both worked OK on another machine, which does not have Visual Studio installed.

What I did differently was to use batch build, and only select the Release|Win32 configurations to build from the list. That fixed it.

Thank you for your help with this. :D

adriano
In need of some credit
In need of some credit
Posts: 1
Joined: Sun Apr 08, 2018 4:08 pm

Re: Linker error - mismatch between release and debug runtime libraries.

Postby adriano » Sun Apr 08, 2018 4:21 pm

Hi All,

I've been trying to statically link MSVC Runtime to minimal example using wxWidgets 3.1.1. and Microsoft Visual Studio Community 2017 Version 15.5.7.

I successfully built all wxWidgets components using the following options:
Windows SDK 10.0.16299.0
Use MFC static library
Debug multi-threaded runtime (/MTd)

The same options were applied to minimal example, but then the linker error occurs:

Code: Select all

LIBCMTD.lib(exe_wwinmain.obj) : error LNK2019: unresolved external symbol _wWinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)


I observed this error occurs when "Use MFC Static library" is selected, otherwise the example compiles fine, but then I wonder if it indeed doesn't require MSVC runtime DLLs.

Could someone help me building this project with static MSVC runtime libs linked to?

Regards,
Adrian

User avatar
doublemax
Moderator
Moderator
Posts: 12672
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linker error - mismatch between release and debug runtime libraries.

Postby doublemax » Sun Apr 08, 2018 6:38 pm

Are you talking about the "minimal" sample that comes with wxWidgets or something else?

wxWidgets does not use MFC, so normally you shouldn't touch that setting. Did you intentionally enable it, because you want to use MFC together with wxWidgets?
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2674
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Linker error - mismatch between release and debug runtime libraries.

Postby ONEEYEMAN » Mon Apr 09, 2018 3:13 pm

Hi,
If you do want to use both MFC and wxWidgets - try to build 'mfc' sample. If it will build correctly - try to copy all settings from the sample to your project.

Thank you.


Return to “Compiler / Linking / IDE Related”

Who is online

Users browsing this forum: No registered users and 5 guests