using MSVC prebuilt binaries in Visual Studio (Step by Step settings)

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
willyywt
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Jun 30, 2020 12:56 pm

using MSVC prebuilt binaries in Visual Studio (Step by Step settings)

Post by willyywt » Wed Jul 01, 2020 11:57 am

Here's the steps I tried successfully configuring a new Visual Studio 2019 .sln project, using the prebuilt dynamic linked libraries from the official site (version 3.1.3). If you see confusing errors like 'error LNK2019: unresolved external symbol _main' , 'unable to open included ../../../lib/vc_dll/mswud/wx/setup.h', you can try these steps.

1. First, you'll need the offical headers and prebuilt development files:
"wxWidgets-3.1.3-headers.7z"
"wxMSW-3.1.3_vc14x_Dev.7z"

Confirm your CPU architecture. As x86 runs on a x86-64 machine, you can simply use x86 in all cases; if you prefer x64 then you need to download the development files with '_x64' and configure the 'x64' in Visual Studio later.

2. Create a new 'Empty Project' Visual Studio Project. Extract everything you downloaded to the same folder with the new .sln file. (If you use 7-zip GUI you can unclick the checkbox with '*\' so 7-zip doesn't automatically create a folder for each .7z file, but extract directly into .sln folder)

3. You will need a updated wxwidgets.props file from the github repository. (wxWidgets 3.0.5 version doesn't comes with this file; 3.1.3 does. Nevertheless, they are both not useful as they don't work well with prebuilt directory names like 'vc14x_dll' or 'vc14x_x64_dll', they are aimed at compiling the libraries yourself and always use 'vc_dll' for compability. The updated wxwidgets.props works with any prefix/dll combinations.)

The updated version:
https://github.com/wxWidgets/wxWidgets/ ... 0a1f8902c1
(The latest in wxWidgets/wxWidgets/wxwidgets.props is better as it fixed a missing slash '/' in comments, but this version is sufficient to work)

Download this updated wxwidgets.props file and download it to your .sln folder. Replace the existing file.

4. Apply the .props file to your .sln project.
In Visual Studio:
Property Manager -> (Right Click your project) -> Add Existing property Sheet -> (Select the wxwidgets.props file)
You should be able to expand the project settings and see 'wxwidgets' and its child 'wx_setup' (the child is already located in .\build\msw\wx_setup.props)

If you don't see 'Property Manager', set View -> Other Windows -> Prpperty Manager

5. As in viewtopic.php?t=35178, you need to change the application type. Using the 'console' application will lead to linking error "error LNK2019: unresolved external symbol _main".
In Visual Studio:
Project settings -> Linker -> General -> System -> Subsystem: Windows

6. In 'Solution Explorer' add your .cpp source file to the .sln project. You can just use an Hello World example from https://docs.wxwidgets.org/stable/overv ... world.html

7. Build your project. You can confirm the required settings as in offical site
https://www.wxwidgets.org/blog/2012/08/ ... -binaries/
just right click 'wxwidgets' (or click and press Alt+Enter). If you use an updated version of wxwidgets.props, the properties shoud work by default.

Your Visual Studio should have at least MSVC compiler and Windows 10 SDK (as for Windows 7/8 and before... I don't know, I am just a beginner:)

The project should build successfully. You can try changing between 'Debug' and 'Release' button. As you run the executable, you should receive errors about the missing .dll files, just paste these files to your .exe folder and run again. (The 'Release' version dll files does not came from build version, download for the release version)

Post Reply