C/C++ cross compilation with arm-none-eabi-gcc

Hello,

I am trying to configure Gradle to use ARM gcc cross compiler (https://launchpad.net/gcc-arm-embedded)
It is configured properly, I can access it from the console.
My problem is that all the toolchain executables have the “arm-none-eabi” prefix, for instance “arm-none-eabi-gcc.exe”.
Could you please explain how to tell gradle to use such prefix ? Thanks.

I have found a related topic 2 years old without any answer.

Thanks for the support

See this post for how you can set the executable for each platform: Having gradle compile with g++ and not gcc. You can use tools.platform to access the individual platform and make a choice about what executable to use.

Hi Gary,

I have modified my build script accordingly, gradle is now looking for the correct executable but I am still getting a bunch of errors

apply plugin: 'c'

model {
    buildTypes {
        debug
        release
    }

    platforms {
      ARM {
        architecture "arm"
      }
    }

    toolChains {
      gcc(Gcc) {
        eachPlatform { tools ->
            tools.cCompiler.executable = "arm-none-eabi-gcc"
        }
      }
    }

    components {
      crc16(NativeLibrarySpec){

      }
      framing(NativeLibrarySpec) {

      }
      telemetry(NativeLibrarySpec) {
        binaries.all {
          lib library: "crc16"
          lib library: "framing"
        }
      }
      main(NativeExecutableSpec) {
          binaries.all {
            lib library: "telemetry"
            lib library: "crc16"
            lib library: "framing"
          }
  	  }
      tests(NativeExecutableSpec) {
         binaries.all {
           lib library: "telemetry"
           lib library: "crc16"
           lib library: "framing"
         }
       }
     }

Here is the build output

:assemble FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':assemble'.
> No buildable binaries found:
    - shared library 'crc16:debug:sharedLibrary': No tool chain is available to
build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - static library 'crc16:debug:staticLibrary': No tool chain is available to
build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - shared library 'crc16:release:sharedLibrary': No tool chain is available t
o build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - static library 'crc16:release:staticLibrary': No tool chain is available t
o build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
- shared library 'framing:debug:sharedLibrary': No tool chain is available t
o build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - static library 'framing:debug:staticLibrary': No tool chain is available t
o build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - shared library 'framing:release:sharedLibrary': No tool chain is available
 to build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - static library 'framing:release:staticLibrary': No tool chain is available
 to build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - executable 'main:debug:executable': No tool chain is available to build fo
r platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - executable 'main:release:executable': No tool chain is available to build
for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - shared library 'telemetry:debug:sharedLibrary': No tool chain is available
 to build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - static library 'telemetry:debug:staticLibrary': No tool chain is available
 to build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - shared library 'telemetry:release:sharedLibrary': No tool chain is availab
le to build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - static library 'telemetry:release:staticLibrary': No tool chain is availab
le to build for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - executable 'tests:debug:executable': No tool chain is available to build f
or platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.
    - executable 'tests:release:executable': No tool chain is available to build
 for platform 'windows_x86':
        - Tool chain 'gcc' (GNU GCC): Could not determine GCC version: failed to
 execute arm-none-eabi-gcc.exe -m32 -dM -E -.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 10.77 secs

arm-none-eabi-gcc is well accessible from the console though

C:\Users\*****\Documents\GitHub\Telemetry>arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=c:/freescale/kds_3.0.0/toolchain/bin/../lib/gcc/arm-none-eab
i/4.9.3/lto-wrapper.exe
Target: arm-none-eabi
Configured with: /home/build/work/GCC-4-9-build/src/gcc/configure --build=i686-l
inux-gnu --host=i686-w64-mingw32 --target=arm-none-eabi --prefix=/home/build/wor
k/GCC-4-9-build/install-mingw --libexecdir=/home/build/work/GCC-4-9-build/instal
l-mingw/lib --infodir=/home/build/work/GCC-4-9-build/install-mingw/share/doc/gcc
-arm-none-eabi/info --mandir=/home/build/work/GCC-4-9-build/install-mingw/share/
doc/gcc-arm-none-eabi/man --htmldir=/home/build/work/GCC-4-9-build/install-mingw
/share/doc/gcc-arm-none-eabi/html --pdfdir=/home/build/work/GCC-4-9-build/instal
l-mingw/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --disable-decim
al-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libqu
admath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared -
-disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-headers=yes --
with-newlib --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/home/build
/work/GCC-4-9-build/install-mingw/arm-none-eabi --with-libiconv-prefix=/home/bui
ld/work/GCC-4-9-build/build-mingw/host-libs/usr --with-gmp=/home/build/work/GCC-
4-9-build/build-mingw/host-libs/usr --with-mpfr=/home/build/work/GCC-4-9-build/b
uild-mingw/host-libs/usr --with-mpc=/home/build/work/GCC-4-9-build/build-mingw/h
ost-libs/usr --with-isl=/home/build/work/GCC-4-9-build/build-mingw/host-libs/usr
--with-cloog=/home/build/work/GCC-4-9-build/build-mingw/host-libs/usr --with-li
belf=/home/build/work/GCC-4-9-build/build-mingw/host-libs/usr --with-host-libstd
cxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU
Tools for ARM Embedded Processors' --with-multilib-list=armv6-m,armv7-m,armv7e-m
,cortex-m7,armv7-r
Thread model: single
gcc version 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 224288] (
GNU Tools for ARM Embedded Processors)

Do you have any ideas on why it’s not working ?

I will try to set the platform to arm and target to arm-none-eabi to see if that changes something

1 Like