Visual Studio 2022 - Release Build Topic is solved

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.
Post Reply
enricovittorini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Nov 07, 2022 2:54 pm

Visual Studio 2022 - Release Build

Post by enricovittorini »

hello all,
i am trying to compile my code as "Release" is Visual Studio 2022, but i get the following errors:

Code: Select all

Error	LNK1120	5 unresolved externals								
Error	LNK2001	unresolved external symbol __imp__calloc_dbg		
Error	LNK2001	unresolved external symbol __imp__CrtDbgReport		
Error	LNK2001	unresolved external symbol __imp__free_dbg			
Error	LNK2001	unresolved external symbol __imp__invalid_parameter	
Error	LNK2001	unresolved external symbol __imp__malloc_dbg		
do you have any clue?

In debug mode it is compiled correctly
thanks!
enricovittorini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Nov 07, 2022 2:54 pm

Re: Visual Studio 2022 - Release Build

Post by enricovittorini »

I removed the _DEBUG from the C++ PreProcessor.
Not i get a messagebox windows saying
The code execution cannot proceed because wxmsw32u_core_vc14x_x64.dll was not found. Reinstalling the program may fix this problem.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Visual Studio 2022 - Release Build

Post by PB »

Make sure your Release configuration links to the release version of wxWidgets (and the CRT) and the Debug one to the debug version of the libraries (_DEBUG is defined by MSVS when linking to the debug CRT, i.e., with /MTd / MDd).

The missing DLL means what is says it means. For the development purposes, I just add in the project's Configuration Properties /Debugging / Enviroment something like

Code: Select all

PATH=$(WXWIN)\lib\vc_x64_dll
so that the application can find wxWidgets libraries when run from MSVS (your DLL location may be different). Obviously, all the DLLs (wxWidgets, CRT, and possibly others) need to be shipped with the application and properly installed.
enricovittorini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Nov 07, 2022 2:54 pm

Re: Visual Studio 2022 - Release Build

Post by enricovittorini »

Thanks PB:
my release setup is the following:

Linker--> General-->Additional Libraries Dependencies
$(wxwin)\lib\vc143_x64_dll;

C++ --> Preprocessor Definitions:
WINDOWS
WXUSINGDLL
wxMSVC_VERSION_AUTO

C++ -->General--> Additional Include Libraries:
$(wxwin)\include\msvc;$(wxwin)\include

Anything else I should take care of?
thanks for your help!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Visual Studio 2022 - Release Build

Post by PB »

enricovittorini wrote: Thu Dec 01, 2022 6:59 am Anything else I should take care of?
I don't think so. Except when including wx.rc (recommended), Resources / Additional Include Directories should have

Code: Select all

$(WXWIN)\include
enricovittorini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Nov 07, 2022 2:54 pm

Re: Visual Studio 2022 - Release Build

Post by enricovittorini »

I still have the error when building in Release mode.
The code execution cannot proceed because wxmsw32u_core_vc14x_x64.dll was not found. Reinstalling the program may fix this problem.
sorry but this is the first time i write c++ code and try to build it. I am in learning mode. My goal is to create an exe file that start without additional installatin. My understanding is that I should have static library.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7478
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Visual Studio 2022 - Release Build

Post by ONEEYEMAN »

Hi,
You are using DLL configuration, right?
And the error comes from executing the binary?

Just copy the DLL ri where the executable is located.

Thank you.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Visual Studio 2022 - Release Build

Post by PB »

If you do not want to distribute any DLLs along your application, you need:
1. To link all 3rd party libraries built as static (not all libraries may support static building, wxWidgets does).
2. To link to the CRT statically, both when building the libraries and application.

If you really want static wxWidgets build, you need to build it yourself, the prebuilt binaries are provided only as shared.

Please be advised that static builds are not generally recommended, particularly linking the CRT statically, as this for example means it will not be updated by the "system".
enricovittorini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Nov 07, 2022 2:54 pm

Re: Visual Studio 2022 - Release Build

Post by enricovittorini »

thanks. I tried to build wxWidgets and then add to my project wxwidgets.props file in the Project Manager
Static build worked.
Post Reply