cmake version 4.2.3 is no longer linking properly
20:27 01 Feb 2026

My build used to work until a recent update of MSys2. cmake (4.2.3) and gcc (version 15.2.0) were updated, and my build no longer works.

It appears that cmake is appending a .lib to some of the libraries. Is there some way to prevent this?


[  5%] Linking C shared library libbdj4common.dll
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lm.lib: No such file or directory
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lws2_32.lib: No such file or directory
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lntdll.lib: No such file or directory
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lBcrypt.lib: No such file or directory
collect2.exe: error: ld returned 1 exit status
make[5]: *** [libcommon/CMakeFiles/libbdj4common.dir/build.make:475: libcommon/libbdj4common.dll] Error 1

I took the link line from build/libcommon/CMakeFiles/libbdj4common.dir/build.make , removed the .lib text and ran that, and it links without any problems. So it does appear that the .lib extension is the problem.

Any cmake experts know how to turn this automatic-extension-thingy off?

cd /C/msys64/home/bll/bdj4/src/build/libcommon && \
        /C/msys64/ucrt64/bin/cc.exe -shared -fPIC -g -o libbdj4common.dll \
        -Wl,--out-implib,libbdj4common.lib -Wl,--major-image-version,0,--minor-image-version,0 \
        -Wl,--whole-archive CMakeFiles/libbdj4common.dir/objects.a \
        -Wl,--no-whole-archive  -LC:/msys64/ucrt64/lib -lglib-2.0 -lintl \
        -lm -lws2_32 -lntdll -lBcrypt \
        -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 \
        -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
$ file build/libcommon/libbdj4common.dll
build/libcommon/libbdj4common.dll: PE32+ executable for MS Windows 5.02 (DLL), x86-64, 19 sections

Things I have tried:

$ ls -l /ucrt64/lib/libm.*
-rw-r--r-- 1 bll None 1676 Jan 30 02:56 /ucrt64/lib/libm.a
if (WIN32)
  list (INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .dll)
  list (INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .a)
endif()

Did not help. It is still appending .lib, even though .a is second in the find-list.

The workaround, run this after creating the cmake build tree:

#!/bin/bash
#

flist=$(find ./build -name 'build.make')
sed -i 's,-l\([^\.]*\)\.lib,-l\1,g' ${flist}
windows cmake msys2