I’m having a lot of fun these days with my Raspberry-pi! Since I’ve already built my own tool chain to cross-compile from my Windows plus Cygwin machine and setup my IDE to compile and debug my software using it, I finally started to compile some projects. Unfortunately I had to face a couple of problems: how to make the ./configure script use my tool chain to generate Raspberry-Pi binaries in cygwin? Also, how to make CMake use the aforementioned tool chain in cygwin?
How to make the ./configure script use my tool chain to generate Raspberry-Pi binaries in cygwin?
If the tool chain root path is /opt/cross/x-tools/arm-unknown-linux-gnueabi then I manually tell the ./configure script where to find my tools (just copy the command and execute it in the shell!):
CC=/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc \\ CXX=/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++ \\ LD=/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-ld \\ RANLIB=/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-ranlib \\ STRIP=/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-strip \\ CFLAGS="-I/opt/cross/x-tools/arm-unknown-linux-gnueabi/include" \\ LDFLAGS="-L/opt/cross/x-tools/arm-unknown-linux-gnueabi/lib" \\ ./configure \\ –host=arm-unknown-linux-gnueabi \\ –target=arm-unknown-linux-gnueabi \\ –build=i686-pc-cygwin \\ –prefix=$HOME/arm-pi
If everything went smoothly, just issue the make and make install commands to install the software.
How to make CMake use the aforementioned tool chain in cygwin?
Simply by passing CMake a “tool chain file” path as argument, that is to say a file which tells CMake where to find tool chain files and which flags to use.
- Download the tool chain file from my github repository (HERE) and save it to /home/<username>.
- Open the tool chain file and modify the line
set(ARMRPI\_TOOLCHAIN\_ROOT /opt/cross/x-tools/arm-unknown-linux-gnueabi)with the correct tool chain root path.
- Move to the directory of the project you need to compile and issue the command cmake -DCMAKE_TOOLCHAIN_FILE=/home/<username>/arm-pi.toolchain.cmake -G”Unix Makefiles”.
Hopefully CMake should have generated your project makefiles to make it compile using our tool chain!