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:
- 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
andRelease
configurations. - Rebuild wxWidgets from scratch with these new settings.
- 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) forDebug
.
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.
- 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
- Option 1: Rebuild wxWidgets with
/MT
to match your app if you want a fully standalone, statically-linked executable. - 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:
- 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
andRelease
configurations. - Rebuild wxWidgets from scratch with these new settings.
- 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) forDebug
.
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.
- 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
- Option 1: Rebuild wxWidgets with
/MT
to match your app if you want a fully standalone, statically-linked executable. - 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!