I was trying to build CMake 3.20.3 on Windows 10 using MinGW-W64 8.1.0 and Ninja. It seems to me that the KWSys 2021-05-07 update causes compilation errors with this setup. I can post the errors if this is useful. Is there guidance on which gcc compiler on Windows I should use for building CMake?
Posting errors would be helpful. We are testing GCC 9.2.0 regularly at least. I also see a GCC 4.9.3 nightly runner.
Cc: @brad.king
Below is the error. For clarification v3.20.3 builds fine but building the latest is the problem.
[373/1055] Building CXX object Source/kwsys/CMakeFiles/cmsys.dir/SystemTools.cxx.obj
FAILED: Source/kwsys/CMakeFiles/cmsys.dir/SystemTools.cxx.obj
C:\Users\tbd\Tools\mingw64\bin\c++.exe -DKWSYS_NAMESPACE=cmsys -DUNICODE -D_UNICODE -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=1 -DKWSYS_CXX_HAS_SETENV=0 -DKWSYS_CXX_HAS_UNSETENV=0 -DKWSYS_CXX_HAS_UTIMENSAT=0 -DKWSYS_CXX_HAS_UTIMES=0 -DKWSYS_CXX_STAT_HAS_ST_MTIM=0 -DKWSYS_CXX_STAT_HAS_ST_MTIMESPEC=0 -ISource -ISource/kwsys -std=gnu++17 -MD -MT Source/kwsys/CMakeFiles/cmsys.dir/SystemTools.cxx.obj -MF Source\kwsys\CMakeFiles\cmsys.dir\SystemTools.cxx.obj.d -o Source/kwsys/CMakeFiles/cmsys.dir/SystemTools.cxx.obj -c C:/Users/tbd/Desktop/cmake/cmake_ninja_gcc_old/Source/kwsys/SystemTools.cxx
C:/Users/tbd/Desktop/cmake/cmake_ninja_gcc_old/Source/kwsys/SystemTools.cxx: In static member function 'static cmsys::Status cmsys::SystemTools::CreateSymlink(const string&, const string&)':
C:/Users/tbd/Desktop/cmake/cmake_ninja_gcc_old/Source/kwsys/SystemTools.cxx:3091:13: error: 'SYMBOLIC_LINK_FLAG_DIRECTORY' was not declared in this scope
flags = SYMBOLIC_LINK_FLAG_DIRECTORY;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Users/tbd/Desktop/cmake/cmake_ninja_gcc_old/Source/kwsys/SystemTools.cxx:3091:13: note: suggested alternative: 'SYMLINK_FLAG_RELATIVE'
flags = SYMBOLIC_LINK_FLAG_DIRECTORY;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
SYMLINK_FLAG_RELATIVE
C:/Users/tbd/Desktop/cmake/cmake_ninja_gcc_old/Source/kwsys/SystemTools.cxx:3100:8: error: 'CreateSymbolicLinkW' was not declared in this scope
if (!CreateSymbolicLinkW(newPath.c_str(), origPath.c_str(),
^~~~~~~~~~~~~~~~~~~
C:/Users/tbd/Desktop/cmake/cmake_ninja_gcc_old/Source/kwsys/SystemTools.cxx:3100:8: note: suggested alternative: 'CreateSymlink'
if (!CreateSymbolicLinkW(newPath.c_str(), origPath.c_str(),
^~~~~~~~~~~~~~~~~~~
CreateSymlink
C:/Users/tbd/Desktop/cmake/cmake_ninja_gcc_old/Source/kwsys/SystemTools.cxx:3109:10: error: 'CreateSymbolicLinkW' was not declared in this scope
if (!CreateSymbolicLinkW(newPath.c_str(), origPath.c_str(), flags)) {
^~~~~~~~~~~~~~~~~~~
C:/Users/tbd/Desktop/cmake/cmake_ninja_gcc_old/Source/kwsys/SystemTools.cxx:3109:10: note: suggested alternative: 'CreateSymlink'
if (!CreateSymbolicLinkW(newPath.c_str(), origPath.c_str(), flags)) {
^~~~~~~~~~~~~~~~~~~
CreateSymlink
We are testing GCC 9.2.0 regularly at least. I also see a GCC 4.9.3 nightly runner.
The GCC 9.2.0 testing does build CMake and works. The GCC 4.9.3 testing is only driving the CMake test suite, but uses a CMake built by another compiler.
the KWSys 2021-05-07 update causes compilation errors
In particular, that update included KWSys MR 216, which added use of CreateSymbolicLinkW
and SYMBOLIC_LINK_FLAG_DIRECTORY
. They are part of the Windows SDK, and work with MinGW’s GCC 9.2.0 package, but perhaps older MinGW toolchains do not have the declarations in their Windows headers.
It looks like GCC 9.2.0 is only available through MSYS2 packages. I had been using the GCC only package at MinGW-w64 - for 32 and 64 bit Windows - Browse /mingw-w64 at SourceForge.net, which shows GCC . Is using MSYS2 the preferred compiler environment?
There are msys2-runtime packages and MinGW packages. The latter is needed to build a CMake that targets Windows platforms. Our nightly build with GCC 9.2.0 uses MinGW packages. They are available through the MSYS2 package manager.
I’m seeing the same build error while cross-compiling cmake with Mingw-w64 in Yocto builds.
Quick fix was to add compiler definitions to kwsys that enable the windows API to be available
add_definitions(-D_WIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600)