Simple sample wxWidgets CMake project for all platforms, especially using Vcpkg and Visual Studio on Windows
There has not been an almost standard way to organize C++ development packages on Windows. On Linux or MacOS it's much simpler. Microsoft Vcpkg is quite a good package manager for Windows, that can help a lot. It was hard to get started with wxWidgets and it could take hours to everything set up. Here is simple sample project for a quick start. C++ layout files are generated with wxFormBuilder.
Build status | Systems / Compilers | CI |
---|---|---|
Windows VCPKG | AppVeyor | |
Windows wxWidgets source Win64 | AppVeyor | |
Windows wxWidgets source Win32 | AppVeyor | |
Ubuntu Linux GNU 5.4.0 | AppVeyor | |
MacOS | AppVeyor |
- Windows 10, 8.1, 7, Linux, or MacOS
- Visual Studio 2017 or Visual Studio 2019 (on Windows)
- Git
- CMake (version 3.14 or later for Visual Studio 2019)
- wxFormBuilder
First, install Vcpkg according to instructions. You can install wxWidgets all available targets:
.\vcpkg install wxwidgets:x64-windows
.\vcpkg install wxwidgets:x64-windows-static
.\vcpkg install wxwidgets:x86-windows
.\vcpkg install wxwidgets:x86-windows-static
Batch file buildmsvc.bat is using environment variable VCPKG. Set it according to your Vcpkg directory location before running:
SET VCPKG=C:\VCPKG
Then clone git directory and build:
git clone https://github.com/asjadenet/wxhellovcpkg.git
cd wxhellovcpkg
buildmsvc.bat
You can specify different targets using command line arguments. For example:
buildmsvc.bat Win32 Debug dynamic
For using Visual Studio 2019, set envionment variable WX_VS_VER before building:
SET WX_VS_VER=2019
Sometimes it's better to build wxWidgets libraries from source. For example, source code examples are easier to build and run. Use batch file installwx.bat for this:
Environment variable WX_INSTALL_PATH default value is C:\wxlibs, but you can modify it whenever you want to put wxWidgets libraries and headers.
installwx.bat
It calls batch file initwx.bat. 7zip is necessary for unzipping. Make sure 7z is in your path.
For different targets use command line arguments:
installwx.bat Win32 Debug dynamic
If you want to build samples also, add fourth parameter samples.
installwx.bat Win64 Release static samples
For using Visual Studio 2019, set envionment variable WX_VS_VER before building:
SET WX_VS_VER=2019
If you want to modify helloworld app source code and build, it's necessary only to call build-wxhello.bat.
build-wxhello.bat
For different targets use command line arguments:
build-wxhello.bat Win32 Release static
Install build environment and all dependencies. Here is example how to install cmake and wxWidgets:
pacman -S mingw-w64-i686-cmake mingw-w64-x86_64-cmake
pacman -S mingw-w64-i686-wxWidgets mingw-w64-x86_64-wxWidgets
Then clone git directory and build:
git clone https://github.com/asjadenet/wxhellovcpkg.git
cd wxhellovcpkg
In 64-bit shell run:
./buildmsys64.sh
In 32-bit shell run:
./buildmsys32.sh
Your can install wxwidgets on Ubuntu Linux using command:
sudo apt-get install libwxgtk3.0-dev
Then clone git directory and build:
git clone https://github.com/asjadenet/wxhellovcpkg.git
cd wxhellovcpkg
chmod +x buildmaclinux.sh
./buildmaclinux.sh
Note:
If you get error warning like this:
Warning: Mismatch between the program and library build versions detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1009,wx containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1011,wx containers,compatible with 2.8).
It's better to install wxWidgets from source using:
sudo apt-get install libgtk-3-dev
./configure
make
sudo make install
sudo ldconfig
Your can just install wxwidgets using command:
brew install wxmac
Then clone git directory and build:
git clone https://github.com/asjadenet/wxhellovcpkg.git
cd wxhellovcpkg
chmod +x buildmaclinux.sh
./buildmaclinux.sh