# Cross compile for DevkitPPC

**URL:** <https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899>\
**Category:** Code\
**Created:** [August 10, 2021, 9:22pm UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899 "2021-08-10T21:22:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lgreen9800](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/c57346/32.png) [@Lgreen9800](https://discourse.cmake.org/u/Lgreen9800)\
**Post date:** [August 10, 2021, 9:22pm UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899/1 "2021-08-10T21:22:21Z")

</div>

Hello,

I am trying to build a cmake project that will use the devkitppc toolchain inorder to cross compile from windows to Nintendo Wii.

This involves using the powerpc-eabi-gcc compiler, I include the toolchain file that I have constructed, and then make a call to the project() command. At this point the C compiler is then reverted back to msvc. If my understanding is correct, cmake runs a test on the compiler to make sure that it can compile a basic program, and then if not, it reverts back to the default?

One of my questions would be, what can I do in order to ensure that the compiler passes these tests? or how can I check why it fails?

Or is it even possible to use a custom compiler with the visual studios generator at all?

Thanks for your time,  
All the best,  
Lawrence

---

<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:** [August 10, 2021, 9:56pm UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899/2 "2021-08-10T21:56:55Z")

</div>

Are you using a non-VS generator? I believe the default is to use the VS generator which is going to default to searching for MSVC.

Blah. Now I see the last paragraph. I believe that VS support for a toolchain must be made through VS’ mechanisms and selected via the `-T` flag which chooses the toolchain that will be in effect. I would recommend using the `Ninja` generator and loading the project using VS’ CMake project support that way.

---

<div class="post-metadata">

**Author:** ![Lgreen9800](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/c57346/32.png) [@Lgreen9800](https://discourse.cmake.org/u/Lgreen9800)\
**Post date:** [August 11, 2021, 5:32pm UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899/3 "2021-08-11T17:32:03Z")

</div>

Hello,

So I looked at doing a ninja build. it still says that :

/devkitPPC/bin/powerpc-eabi-gcc  
is not a full path to an existing compiler tool.

Checking the CMake error log I find  
"The C compiler identification could not be found in “/CMakeFiles/3.20.3/CompilerIdC/a.out” "

---

<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:** [August 11, 2021, 6:32pm UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899/4 "2021-08-11T18:32:59Z")

</div>

I would guess at this point that a MinGW-aware CMake is needed. You can get it from the MSYS2 development environment, though I’m unfamiliar with the devkitPCC runtime situation.

---

<div class="post-metadata">

**Author:** ![Lgreen9800](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/c57346/32.png) [@Lgreen9800](https://discourse.cmake.org/u/Lgreen9800)\
**Post date:** [September 13, 2021, 10:04pm UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899/5 "2021-09-13T22:04:17Z")

</div>

Hello,

Apologies for the long delay. Seemingly visual studios is not a good generator. I’ve made a bit of progress, Using any generator on WSL generates a working build system.

I’ve also now managed to get the compiler tests to pass on windows when using ninja or “MSYS Makefiles” generator, however when enabling C as a language there is an error.

> Configuring build for Wii  
> – The C compiler identification is GNU 10.2.0  
> – The CXX compiler identification is GNU 10.2.0
> 
> CMake Error at CMake/Toolchains/Platforms.cmake:44 (enable\_language):  
> The CMAKE\_C\_COMPILER:
> 
> C:/devkitPro/devkitPPC/bin/powerpc-eabi-gcc  
> is not a full path to an existing compiler tool.

Now here’s the interesting part. So copying and pasting that exact path confirms that the compiler is at that location. On top of that, there is no error file inside of build/CMakeFiles.

Checking inside of CMakeOutput.log it confirms that the compilation of the test programs worked?

> The target system is: Generic - 1 - powerpc-eabi  
> The host system is: Windows - 10.0.19042 - AMD64  
> Compiling the C compiler identification source file “CMakeCCompilerId.c” succeeded.  
> Compiler: C:/devkitPro/devkitPPC/bin/powerpc-eabi-gcc  
> Build flags: -Wall;-Wextra;-DGEKKO;-mrvl;-mcpu=750;-meabi;-mhard-float;-LC:/Users/devkitPro/libogc/lib/wii;-lwiiuse;-lbte;-logc;-lm  
> Id flags:
> 
> The output was:  
> 0
> 
> Compilation of the C compiler identification source “CMakeCCompilerId.c” produced “a.out”
> 
> The C compiler identification is GNU, found in “{Build path omitted}/build/CMakeFiles/3.20.3/CompilerIdC/a.out”

With there being no errors listed in build/CMakeFiles I’m not sure how CMake is deciding that this compiler “is not a full path to an existing compiler tool.”

Thank you for your time and help

---

<div class="post-metadata">

**Author:** ![fdk17](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/ea666f/32.png) [@fdk17](https://discourse.cmake.org/u/fdk17)\
**Post date:** [September 14, 2021, 12:10am UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899/6 "2021-09-14T00:10:07Z")

</div>

> [@Lgreen9800](#):
>
> The target system is: Generic - 1 - powerpc-eabi  
> The host system is: Windows - 10.0.19042 - AMD64

> [@Lgreen9800](#):
>
> C:/devkitPro/devkitPPC/bin/powerpc-eabi-gcc  
> is not a full path to an existing compiler tool.

Windows executables end typically with a `.exe`. It’s been a while since I’ve messed with running CMake in a MSYS shell but you have to be careful of using backslashes and forward slashes and the `.exe` extension.

In a clean build try running CMake with one of the `--trace` options and you’ll see where it is failing. If I recall correctly something like `get_filename_component` is used to verify that the compiler exists in the filesystem. But because the `.exe` is missing from the path then it fails the filesystem check and that is where it chokes.

---

<div class="post-metadata">

**Author:** ![Lgreen9800](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/c57346/32.png) [@Lgreen9800](https://discourse.cmake.org/u/Lgreen9800)\
**Post date:** [September 14, 2021, 8:18pm UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899/7 "2021-09-14T20:18:50Z")

</div>

The compiler paths were missing the .exe extension, adding that solved it

Thank you! it was staring me in the face! I’ve been using Msys so long I forgot that windows needs exe
