Failing to detect ABI

I’ve just compiled the latest version of the Clang tools, and I’m trying to make a simple “Hello World” on Windows with Clang and Cmake. Cmake is returning to me an error about being unable to detect the ABI interface.

This is my CMakeList.txt file.

cmake_minimum_required(VERSION 4.00)
set(CMAKE_CXX_STANDARD 20	)
project("HelloWorld")
add_executable (HelloWorld "HelloWorld.cpp" "HelloWorld.h")

I’ve got a cmake_tools.cmake file to go along with it.

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER clang.exe)
set(CMAKE_CXX_COMPILER clang++.exe)

I build with the following command.

cmake -GNinja -DLLVM_ENABLE_PROJECTS=clang -DMAKE_TOOLCHAIN_FILE=..\cmake_tools.cmake .. --debug-trycompile

I get this output.

debug trycompile on
-- The CXX compiler identification is Clang 21.0.0 with GNU-like command-line
-- Detecting CXX compiler ABI info
CMake Debug Log at C:/Program Files/CMake/share/cmake-4.0/Modules/CMakeDetermineCompilerABI.cmake:81 (try_compile):
  Executing try_compile (CMAKE_CXX_ABI_COMPILED) in:

    C:/shares/projects/j2inet/devsetup/Clang/HelloWorld/HelloWorld/HelloWorld/build/CMakeFiles/CMakeScratch/TryCompile-6e3ty8
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-4.0/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
  CMakeLists.txt:3 (project)


-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: J:/shares/clang/llvm-project/build/Release/bin/clang++.exe
CMake Debug Log at C:/Program Files/CMake/share/cmake-4.0/Modules/CMakeTestCXXCompiler.cmake:56 (try_compile):
  Executing try_compile (CMAKE_CXX_COMPILER_WORKS) in:

    C:/shares/projects/j2inet/devsetup/Clang/HelloWorld/HelloWorld/HelloWorld/build/CMakeFiles/CMakeScratch/TryCompile-2umff4
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


-- Check for working CXX compiler: J:/shares/clang/llvm-project/build/Release/bin/clang++.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-4.0/Modules/CMakeTestCXXCompiler.cmake:73 (message):
  The C++ compiler

    "J:/shares/clang/llvm-project/build/Release/bin/clang++.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: 'C:/shares/projects/j2inet/devsetup/Clang/HelloWorld/HelloWorld/HelloWorld/build/CMakeFiles/CMakeScratch/TryCompile-2umff4'

    Run Build Command(s): J:/shares/Ninja/ninja.exe -v cmTC_5cabd
    [1/2] J:\shares\clang\llvm-project\build\Release\bin\clang++.exe   -O0 -std=gnu++23 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -MD -MT CMakeFiles/cmTC_5cabd.dir/testCXXCompiler.cxx.obj -MF CMakeFiles\cmTC_5cabd.dir\testCXXCompiler.cxx.obj.d -o CMakeFiles/cmTC_5cabd.dir/testCXXCompiler.cxx.obj -c C:/shares/projects/j2inet/devsetup/Clang/HelloWorld/HelloWorld/HelloWorld/build/CMakeFiles/CMakeScratch/TryCompile-2umff4/testCXXCompiler.cxx
    [2/2] C:\WINDOWS\system32\cmd.exe /C "cd . && J:\shares\clang\llvm-project\build\Release\bin\clang++.exe -nostartfiles -nostdlib -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -Xlinker /subsystem:console -fuse-ld=lld-link CMakeFiles/cmTC_5cabd.dir/testCXXCompiler.cxx.obj -o cmTC_5cabd.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:cmTC_5cabd.lib -Xlinker /pdb:cmTC_5cabd.pdb -Xlinker /version:0.0   -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cd ."
    FAILED: cmTC_5cabd.exe
    C:\WINDOWS\system32\cmd.exe /C "cd . && J:\shares\clang\llvm-project\build\Release\bin\clang++.exe -nostartfiles -nostdlib -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -Xlinker /subsystem:console -fuse-ld=lld-link CMakeFiles/cmTC_5cabd.dir/testCXXCompiler.cxx.obj -o cmTC_5cabd.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:cmTC_5cabd.lib -Xlinker /pdb:cmTC_5cabd.pdb -Xlinker /version:0.0   -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cd ."
    clang++: error: unable to execute command: program not executable
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


-- Configuring incomplete, errors occurred!

Any idea what’s going on or how to resolve this?

Someone in another forum pointed me to the right direction. I needed to add the path to Visual Studio’s link.exe to my path. After doing that, the build worked fine.