WxWidgets App build Error Visual Studio 2019

Filippo Taurian 41 Reputation points
2021-05-26T09:10:19.387+00:00

I built a wxwidgets c ++ program with visual studio 2019, on my pc there were no problems, but when i tried to start it on another pc i got a missing libraries message. I searched the internet and was advised to change the code generation settings from DLLMultiThread (/ MD) to MultiThread (/ MT), I re-built the project and got several error messages like:

1> wxbase31u.lib (string.obj): error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (thread.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (list.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (appbase.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (time.obj): error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (hashmap.obj): error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match value 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (object.obj): error LNK2038: found mismatch for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (strconv.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (log.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (event.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (stringimpl.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (strvararg.obj): error LNK2038: found mismatch for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match value 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (unichar.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (stringops.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (intl.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (wxcrt.obj): error LNK2038: found mismatch for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match value 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (xlocale.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (dummy.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (module.obj): error LNK2038: found mismatch for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match value 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (msgout.obj): error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match value 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (translation.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (utils.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (main.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (threadinfo.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (arrstr.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (config.obj): error LNK2038: mismatch found for 'RuntimeLibrary': value 'MD_DynamicRelease' does not match 'MT_StaticRelease' in Window.obj
1> wxbase31u.lib (stdpbase.obj): error LNK2038: found mismatch for 'RuntimeLibrary': value 'MD_DynamicRelease'

(maybe these are not exactly the warnings because I had to translate them from my language):

what am i doing wrong? I can not understand.

Developer technologies | C++
Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

Accepted answer
  1. rostanchase 80 Reputation points
    2024-11-06T07:22:33.9633333+00:00

    The issue you’re facing is due to a mismatch between the runtime library settings of your wxWidgets library and your application project in Visual Studio. When you switched your project’s runtime from MD (DLL, dynamically linked) to MT (static linking), the runtime libraries used by wxWidgets (built with /MD) no longer match your application (now using /MT). This causes linker errors like LNK2038.

    Here’s how to resolve this:

    1. Rebuild wxWidgets with the /MT Setting

    Since your wxWidgets library is built with the /MD option (dynamic runtime), you’ll need to rebuild wxWidgets with the /MT option (static runtime) so it matches your application.

    • Open your wxWidgets Visual Studio solution (e.g., wx_vcN.sln where N is the Visual Studio version).
    • Go to the Project Properties for each wxWidgets project (like wxbase, wxcore, etc.).
    • Under C/C++ -> Code Generation, set the Runtime Library to Multi-threaded (/MT) for both Debug and Release configurations.
    • Rebuild wxWidgets from scratch with these new settings.
    1. Alternative Solution: Use DLL Runtime /MD for Both

    If you want to avoid rebuilding wxWidgets, revert your project’s runtime setting back to /MD:

    • Open your project in Visual Studio.
    • Go to Project Properties > C/C++ > Code Generation.
    • Set Runtime Library back to Multi-threaded DLL (/MD) for Release and Multi-threaded Debug DLL (/MDd) for Debug.

    Then, instead of embedding all dependencies statically, you can include the necessary Visual C++ Redistributable (or relevant .dll files) with your application when deploying it.

    1. Deploy with Necessary Dependencies

    If you stay with /MD, ensure that the target machine has the required Visual C++ Redistributable installed. Alternatively, you can manually include the .dll files your application needs in the installation package.

    Summary

    1. Option 1: Rebuild wxWidgets with /MT to match your app if you want a fully standalone, statically-linked executable.
    2. Option 2: Revert your application to /MD if you prefer to keep the wxWidgets libraries dynamically linked.

    Choose the method that best fits your deployment needs!The issue you’re facing is due to a mismatch between the runtime library settings of your wxWidgets library and your application project in Visual Studio. When you switched your project’s runtime from MD (DLL, dynamically linked) to MT (static linking), the runtime libraries used by wxWidgets (built with /MD) no longer match your application (now using /MT). This causes linker errors like LNK2038.

    Here’s how to resolve this:

    1. Rebuild wxWidgets with the /MT Setting

    Since your wxWidgets library is built with the /MD option (dynamic runtime), you’ll need to rebuild wxWidgets with the /MT option (static runtime) so it matches your application.

    • Open your wxWidgets Visual Studio solution (e.g., wx_vcN.sln where N is the Visual Studio version).
    • Go to the Project Properties for each wxWidgets project (like wxbase, wxcore, etc.).
    • Under C/C++ -> Code Generation, set the Runtime Library to Multi-threaded (/MT) for both Debug and Release configurations.
    • Rebuild wxWidgets from scratch with these new settings.
    1. Alternative Solution: Use DLL Runtime /MD for Both

    If you want to avoid rebuilding wxWidgets, revert your project’s runtime setting back to /MD:

    • Open your project in Visual Studio.
    • Go to Project Properties > C/C++ > Code Generation.
    • Set Runtime Library back to Multi-threaded DLL (/MD) for Release and Multi-threaded Debug DLL (/MDd) for Debug.

    Then, instead of embedding all dependencies statically, you can include the necessary Visual C++ Redistributable (or relevant .dll files) with your application when deploying it.

    1. Deploy with Necessary Dependencies

    If you stay with /MD, ensure that the target machine has the required Visual C++ Redistributable installed. Alternatively, you can manually include the .dll files your application needs in the installation package.

    Summary

    1. Option 1: Rebuild wxWidgets with /MT to match your app if you want a fully standalone, statically-linked executable.
    2. Option 2: Revert your application to /MD if you prefer to keep the wxWidgets libraries dynamically linked.

    Choose the method that best fits your deployment needs!

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.