# Cross compiling from a Windows host targeting raspbian 32 bits arm

**URL:** https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250
**Category:** Usage
**Created:** [October 23, 2023, 11:30am UTC](https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250 "2023-10-23T11:30:14Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![VivienDelmon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/viviendelmon/32/3938_2.png) [@VivienDelmon](https://discourse.cmake.org/u/VivienDelmon)
#### Post date: [October 23, 2023, 11:30am UTC](https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250/1 "2023-10-23T11:30:14Z")

</div>

Hi,

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.

```auto
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):
  The CMAKE_CXX_COMPILER:

    E:/SysGCC/raspberry/bin/arm-linux-gnueabihf-g++

  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:
0

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 :

```auto
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_SYSTEM_PROCESSOR "armv7")

# 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)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")

# Search for programs only in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search for libraries and headers only in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

```

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 …

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 23, 2023, 6:52pm UTC](https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250/2 "2023-10-23T18:52:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![VivienDelmon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/viviendelmon/32/3938_2.png) [@VivienDelmon](https://discourse.cmake.org/u/VivienDelmon)
#### Post date: [October 24, 2023, 7:23am UTC](https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250/3 "2023-10-24T07:23:00Z")

</div>

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

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

Thanks a lot.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 24, 2023, 11:18am UTC](https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250/4 "2023-10-24T11:18:56Z")

</div>

`.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).

---

<div class="post-metadata">

### Author: ![VivienDelmon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/viviendelmon/32/3938_2.png) [@VivienDelmon](https://discourse.cmake.org/u/VivienDelmon)
#### Post date: [October 24, 2023, 12:05pm UTC](https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250/5 "2023-10-24T12:05:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 24, 2023, 1:06pm UTC](https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250/6 "2023-10-24T13:06:53Z")

</div>

Indeed. I’ll look at that.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 29, 2023, 12:30pm UTC](https://discourse.cmake.org/t/cross-compiling-from-a-windows-host-targeting-raspbian-32-bits-arm/9250/7 "2023-10-29T12:30:44Z")

</div>

Implemented here: [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/8914](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8914)
