Hi, my system is:
Windows 7 x64
wxWidgets 3.1.4 (build=release shared=0 monolithic=0)
GCC MinGW 10.2.0
Visual Studio 2017
cmake 3.18.1
I just wanted to know if my wxWidgets compile is good so I downloaded this project and compiled with VS 2017 and GCC
With VS2017
Configuring with cmake it was a PITA, because you have to either create environmente variables or just pass the variables to cmake to configure wxWidgets, here are the variables, the importants are: wxWidgets_ROOT_DIR, wxWidgets_LIB_DIR, wxWidgets_CONFIGURATION, but after creating those variables cmake was complaining about the variable: wxWidgets_LIBRARIES, and the docs says that this variable will be setted by cmake, don't know why was complaining sure I did something wrong but I don't know, at the end just either create environment variables or just pass the variables to cmake, I created all env vars and just:
cmake -G "Visual Studio 15 2017 Win64" ..
Not tested all projects but the ApplicationAndMain ApplicationAndMain2 gives undefined reference to main, this happens because VS uses its own main function for GUIs that is WinMain, the only way to solve this is to change subsystem to console but this shows the console window, even using the FreeConsole() function to hide the window it still appears for less than 2 seconds
With MinGW GCC
I also have GCC 7.1 and it is my default compiler but this version does not fully support C++17 so I had to configure cmake to select the GCC 10.2 like this:
set mingw64_path=c:/mingw-w64/x86_64-10.2.0-posix-seh/mingw64/bin
set CC=%mingw64_path%/gcc.exe
set CPP=%mingw64_path%/g++.exe
set MAKE=%mingw64_path%/mingw32-make.exe
set RC=%mingw64_path%/windres.exe
cmake -DCMAKE_MAKE_PROGRAM=%MAKE% -DCMAKE_C_COMPILER=%CC% -DCMAKE_CXX_COMPILER=%CPP% -DCMAKE_RC_COMPILER=%RC% -DCMAKE_VERBOSE_MAKEFILE=ON -G "MinGW Makefiles" ..
This generated the Makefiles with no problems
Also there was undefined reference to many functions with the RichTextCtrl project , after digging in internet I found that the libs should be in a specific order and since there are many libs I found this and I changed the file link.txt this part:
... --minor-image-version,0, @CMakeFiles\RichTextCtrl.dir\linklibs.rsp
to
... --minor-image-version,0,--start-group @CMakeFiles\RichTextCtrl.dir\linklibs.rsp
and that solved the libs and the project compiled fine
cmake
Now some tips to get better experience with both MSVC compiler and GCC
- Check if wxWidgets_ROOT_DIR, wxWidgets_LIB_DIR:PATH, wxWidgets_CONFIGURATION vars are set if not show a message that these vars must be set
- Check for minimun compiler version to run C++17 I think GCC is 7 or 8, dont know about MSVC
- Detect wxWidgets compilation options like static (passing -DwxWidgets_USE_STATIC:BOOL=ON) in GCC add -static option and MSVC add option /MT for release and /MTd for debug (passing -DwxWidgets_USE_DEBUG:BOOL=ON) here more info
- Add to the linker the --start-group to solves the libs order