doublemax wrote: ↑Sun Dec 29, 2019 1:41 pm
Building an empty VS studio project with wxWidgets from scratch is not an easy task. A lot of paths, libraries, preprocessor symbols etc. need to be set correctly.
I dare to disagree, it is actually very simple and should be done under five minutes.
The following assumes you have set the
WXWIN environment variable correctly, so its value is something like
c:\wxwidgets. Obviously, it also expects you built the requested configurations of wxWidgets.
For example, a simple guide below shows a wxWidgets-related MSVS project settings one needs to add for a self-built 32-bit DLL Debug configuration of a wxWidgets app. The titles in bold and italics in sections 1-4 correspond to the Configuration Properties of a project. Section 5 also describes modifications of the project needed for Release, Static build or 64-bit build.
Start with using the "Windows Desktop Wizard" to create a new project (from menu File/New/Project). Select "Desktop Application" as "Application Type" and check "Empty project". Then add at least one C++ file to the project.
1
General
Make sure
Character Set is set to "Use Unicode Character Set".
2
C/C++
2.1
General/Additional Include Directories:
Code: Select all
$(WXWIN)\include\msvc; $(WXWIN)\include
2.2
Preprocessor/Preprocessor Definitions:
Click on the combobox arrow next to the text edit, choose "<Edit...>" from the menu and in the "Preprocess Definitions" dialog make sure the checkbox "Inherit from parent or project defaults" is checked.
3
Linker
3.1
General/Additional Library Directories:
When you are using a MSVC-specific include (see step 2.1), all necessary libraries are linked automatically and you do not need to list their names, you just need to tell the linker where they are.
3.2
System
Set
SubSystem as follows, otherwise you will get some odd error about the
main() function not found
4
Resources
The resources options may become available only once you add an .rc file to your project. You should have one, if only to add the application icon.
4.1
General/Additional Include Directories:
5
Additional tips
5.1
Making the wxWidgets DLLs available
If you use the DLL build, you must make the correct wxWidgets DLLs available to your program. Either copy them to the directory where the executable resides or just for running the app from the MSVS in
Debugging set the
Environment to
5.2
Settings for the Release configuration
In the preprocessor definitions (see step 2.2) replace
with
5.3
Static build
If you do not want a DLL build, remove this preprocessor definition (see step 2.2)
and change the linker's library directory (see step 3.1) to
5.4
64-bit build
If you built your libraries in
vc_x64_{lib|dll} folder, you must use this folder everywhere instead of
vc_{lib|dll} folder.
5.5
DPI Awareness
Last but not least, if your application is DPI-aware (it better be in 2020), you should at least set its
DPI Awareness in
Manifest Tool/Input and Output to "High DPI Aware". But it may be better to include a proper application manifest, with Windows version compatibilities listed and having PerMonitorV2 awareness there. However, PMv2 DPI awareness support is not that good yet in wxWidgets, see e.g.
here .
Prebuilt binaries
If you did not build wxWidgets yourself and are using
prebuilt binaries for MSVS 2015/2017/2019/2022 you need to set the linker folder (see step 3.1) to
for the 32-bit version or for 64-bit version to
and add preprocessor definition (see step 2.2)
as the compiler prefix in the folder name for those is
vc14x.
But when using prebuilt binaries, you may be better off using the .props method, see the official documentation or my step-by-step guide.
BTW, I expect you read
this official guide for setting up wxWidgets apps on MSW?