Building wxWidgets with MinGW
I downloaded wxWidgets 3.1.5, extracted it to <EXTERNAL_PROJECTS>/Source/wxwidgets/v3.1.5
and used CMake to build it via these commands:
C:/Program Files/CMake/bin/cmake.exe -S<EXTERNAL_PROJECTS>/Source/wxwidgets/v3.1.5 -B<EXTERNAL_PROJECTS>/Build/wxwidgets/v3.1.5/gnu/amd64/Release -GMinGW Makefiles --loglevel=DEBUG -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_C_COMPILER=C:/msys64/mingw64/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/msys64/mingw64/bin/g++.exe -DCMAKE_RC_COMPILER=C:/msys64/mingw64/bin/windres.exe -DBUILD_SHARED_LIBS=OFF -DwxBUILD_SHARED=OFF -DCMAKE_INSTALL_PREFIX=<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/gnu/amd64/static
C:/Program Files/CMake/bin/cmake.exe --build <EXTERNAL_PROJECTS>/Build/wxwidgets/v3.1.5/gnu/amd64/Release
C:/Program Files/CMake/bin/cmake.exe --install <EXTERNAL_PROJECTS>/Build/wxwidgets/v3.1.5/gnu/amd64/Release
Failing sample Project with MinGW
I am using this very simple sample project to try to find the just before built wxWidgets: cmake-find-wxwidgets.zip (2.5 KB), which I am trying to “build” via this command:
cmake -S . -B build/mingw -G"MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchains/mingw64.toolchain --loglevel=debug -DCMAKE_BUILD_TYPE=Release -DwxWidgets_ROOT_DIR=<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/gnu/amd64/static/
Unfortunately this always fails with:
-- Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS)
wxWidgets NOT found!
Working sample Project with MSVC
Doing the analogous thing with MSVC works just fine. So building via the commands (also done for Debug
configuration):
C:/Program Files/CMake/bin/cmake.exe -S<EXTERNAL_PROJECTS>/Source/wxwidgets/v3.1.5 -B<EXTERNAL_PROJECTS>/Build/wxwidgets/v3.1.5/msvc/amd64/Release -GNMake Makefiles --loglevel=DEBUG -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=/DWIN32 /D_WINDOWS -DCMAKE_CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc -DCMAKE_C_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe -DCMAKE_CXX_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe -DBUILD_SHARED_LIBS=false -DwxBUILD_SHARED=false -DCMAKE_INSTALL_PREFIX=<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static'
C:/Program Files/CMake/bin/cmake.exe --build <EXTERNAL_PROJECTS>/Build/wxwidgets/v3.1.5/msvc/amd64/Release'
C:/Program Files/CMake/bin/cmake.exe --install <EXTERNAL_PROJECTS>/Build/wxwidgets/v3.1.5/msvc/amd64/Release'
and building the above attached sample project via:
cmake -S . -B build/msvc --loglevel=debug -DwxWidgets_ROOT_DIR=<EXTERNAL_PROJECTS>\Install\wxwidgets\v3.1.5\msvc\amd64\static
returns the expected result:
Searching for wxWidgets...
-- Found wxWidgets: debug;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxmsw31ud_core.lib;optimized;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxmsw31u_core.lib;debug;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxbase31ud.lib;optimized;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxbase31u.lib;debug;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxpngd.lib;optimized;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxpng.lib;debug;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxtiffd.lib;optimized;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxtiff.lib;debug;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxjpegd.lib;optimized;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxjpeg.lib;debug;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxzlibd.lib;optimized;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxzlib.lib;debug;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxregexud.lib;optimized;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxregexu.lib;debug;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxexpatd.lib;optimized;<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/msvc/amd64/static/lib/vc_x64_lib/wxexpat.lib;winmm;comctl32;uuid;oleacc;uxtheme;rpcrt4;shlwapi;version;wsock32 (found version "3.1.5") found components: core base png tiff jpeg zlib regex expat
wxWidgets found!
Working sample Project with GNU compilers on Linux
Additionally this works building under Linux using “Unix Makefiles”.
Question
What do I have to do, to find wxWidgets when building with MinGW?