Cross compiling from a Windows host targeting raspbian 32 bits arm


I am having some trouble setting up a cross compiling build environment from a Windows host targeting raspbian 32 bits arm. If I directly use the cross compiler to build a hello world it works fine and run on my target. But as soon as I try to build the same from CMake I cannot find any way to setup things.

MINGW64 ~/work/testArm/build
$ /e/Qt/Tools/CMake_64/bin/cmake -D CMAKE_TOOLCHAIN_FILE=/e/SysGCC/raspberry/rpi_toolchain.cmake -D CMAKE_MAKE_PROGRAM=/e/Qt/Tools/Ninja/ninja.exe -G Ninja ..
-- The CXX compiler identification is GNU 10.2.1
CMake Error at CMakeLists.txt:3 (project):


  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!
See also "C:/Users/vivien.delmon/work/testArm/build/CMakeFiles/CMakeOutput.log".

MINGW64 ~/work/testArm/build
$ cat C:/Users/vivien.delmon/work/testArm/build/CMakeFiles/CMakeOutput.log
The target system is: Linux -  -
The host system is: Windows - 10.0.19045 - AMD64
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: E:/SysGCC/raspberry/bin/arm-linux-gnueabihf-g++
Build flags:
Id flags:

The output was:

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is GNU, found in "C:/Users/vivien.delmon/work/testArm/build/CMakeFiles/3.24.2/CompilerIdCXX/a.out"

My rpi_toolchain.cmake contains the following :


# Specify the cross compiler
set(CMAKE_C_COMPILER ${CMAKE_CURRENT_LIST_DIR}/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_CURRENT_LIST_DIR}/bin/arm-linux-gnueabihf-g++)

# Where is the target environment
set(CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/arm-linux-gnueabihf/sysroot)

# Search for programs only in the build host directories

# Search for libraries and headers only in the target directories

It is the first time I try to setup a cross compiling environment from Windows/CMake and I probably miss something obvious but I cannot find what …

Just a guess, but are you missing a .exe suffix on the compiler path?

1 Like

I hoped you were right after loosing so much time but I was really not convinced. But I tried, and …, it worked :expressionless:

Everywhere (cmd, powershell, git bash, etc.) you can call executable without the ending “.exe” extension but not here :confused:

Thanks a lot.

.exe suffixes are added when searching for something to execute. Having the suffix is necessary for things like EXISTS checks in CMake (which is what I think is done here).

By the way, the error message could be more explicit.
It’s a bit hard to understand when cmake shows a fine result of a compilation from a compiler that it claims not to be found.

Indeed. I’ll look at that.

1 Like

Implemented here: