Using Visual Studio 2017 to Build wxWidgets

About two years ago, I wrote a post outlining how to build wxWidgets using Visual Studio 2015. Since then, wxWidgets has been updated, and Visual Studio is now VS 2017. The procedure I outlined also worked for the first few versions of Visual Studio 2017, but later updates made changes that invalidated some of the steps that I outlined. I also recommended downloading wxWidgets directly from the GitHub code page, a practice that wxWidgets does not recommend.

This post provides a new procedure for building wxWidgets with Visual Studio 2017. It works for wxWidgets 3.0.3, 3.1.0 and hopefully later versions, with Visual Studio 2017 version 15.5.3. Hopefully it will be valid for future updates of Visual Studio as well.

So, let’s begin. I assume you already have Visual Studio 2017 installed with all updates also installed. Here are the steps required to build wxWidgets:

Getting the Source Code

  1. Create a directory to place the wxWidgets source code into. I will assume you call this directory wxWidgets. I have placed mine at C:\wxWidgets. The instructions in this post and two future posts on building a simple wxWidgets program assume this location.
  2. Download the wxWidgets source code. There are two locations to download from, depending on whether you want the latest stable, the latest development release, or the latest bleeding-edge release.
    • For the latest stable or development release, go to the wxWidgets download page. Download the Windows ZIP or Windows 7Z file for the release that you want. At the time that I write this, the latest stable release is 3.0.3, and the latest development release is 3.1.0.
    • For the latest bleeding-edge release go to the GitHub release page. Do not download any of the files at the top of this page. Instead, scroll down the page to the Source Files and Documentation section. Follow the directions provided there. The current bleeding edge release is version 3.1.1-rc.

The instructions for building each of these versions is different, so they are separated here.

Building wxWidgets 3.0.3

  1. Open File Explorer and navigate to the C:\wxWidgets\build\msw directory.
  2. Locate the file wx_vc12.sln and open it. This will start Visual Studio and display the Review Solution Actions dialog:
    reviewsolutionactions
    Select the SDK version that you want to build for, and click on the OK button. The solution will be retargeted for Visual Studio 2017.
  3. By default, Unicode wxWidgets libraries are built. If you do not want Unicode enabled libraries, consult the wxWidgets documentation for how to change this.
  4. In Visual Studio, select the configuration that you want to build. There are four choices for each of 32-bit and 64-bit libraries. You can build all eight if you wish, one at a time.
  5. Select Build->Build Solution from the menu. There will be a number of compiler warnings. You can safely ignore these.

Building wxWidgets 3.1.0

  1. Open File Explorer and navigate to the C:\wxWidgets\build\msw directory.
  2. Locate the file wx_vc14.sln and open it. This will start Visual Studio and display the Review Solution Actions dialog:
    reviewsolutionactions14
    Select the SDK version that you want to build for, and click on the OK button. The solution will be retargeted for Visual Studio 2017.
  3. By default, Unicode wxWidgets libraries are built. If you do not want Unicode enabled libraries, consult the wxWidgets documentation for how to change this.
  4. In Visual Studio, select the configuration that you want to build. There are four choices for each of 32-bit and 64-bit libraries. You can build all eight if you wish, one at a time.
  5. Select Build->Build Solution from the menu. There will be a number of compiler warnings. You can safely ignore these.

Build wxWidgets 3.1.1-rc and later

  1. Open File Explorer and navigate to the C:\wxWidgets\build\msw directory.
  2. Locate the file wx_vc15.sln and open it. This will start Visual Studio and load the solution.
  3. By default, Unicode wxWidgets libraries are built. If you do not want Unicode enabled libraries, consult the wxWidgets documentation for how to change this.
  4. In Visual Studio, select the configuration that you want to build. There are four choices for each of 32-bit and 64-bit libraries. You can build all eight if you wish, one at a time.
  5. Select Build->Build Solution from the menu. If during the build, you get error messages that look like:
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\v141\Toolset.targets(34,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".

    then the solution is attempting to build against a version of the Windows SDK that you do not have on your computer. You have two choices here:

    • Install the corresponding version of the Windows SDK; or,
    • Retarget the solution to a Windows SDK version that is installed. Note that you will probably be limited to versions 8.1 and 10.
      To retarget, right click the solution in the Solution Explorer and select Retarget Solution. This will open the Review Solution Actions dialog:
      retargetsolutionactions
      Select the Windows SDK version and click OK. Rebuild the solution.

    There will be a number of compiler warnings. You can safely ignore these.

Advertisements

4 thoughts on “Using Visual Studio 2017 to Build wxWidgets

  1. Pingback: Visual Studio 2015 and wxWidgets 3.0.2 | Using C++

  2. Pingback: Creating wxWidgets Programs with Visual Studio 2017 – Part 1 | Using C++

  3. Build worked fine, thanx for the instructions! One small problem occurs.
    – I open an existing project
    – I replaced all include and lib paths by current wxWidgets directory
    – I compiled successfully
    But in code editor each command to wxWidgets is underlined red. So I cannot preview class members or function arguments needed.

    Like

  4. Pingback: VS2017与wxWidgets的开发环境配置(仅静态链接) | 沉默的猫

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s