Building Cross-GDB in the MinGW VM
1. Compile and install libexpat
- Download source code of libexpat from the official website: https://expat.sourceforge.net/
- Boot MinGW virtual machine.
- Import expat-2.1.1.tar.gz into the virtual machine and copy it to C:\MinGW\msys\1.0\opt folder
- Open MSYS shell and run the following commands:
cd /opt tar zxf expat-2.1.1.tar.gz cd expat-2.1.1 ./configure make make install cd .. rm -rf expat-2.1.1 rm expat-2.1.1.tar.gz exit
2. Prepare to build GDB
- Assign the following contents to the C:\MinGW\msys\1.0\opt\crosstool\src\build_cross_toolchain.sh:
#!/bin/bash export PATH=.:/usr/local/bin:/bin:/c/MinGW/bin export PATH=$PATH:/c/WINDOWS/system32:/c/WINDOWS export PATH=$PATH:/c/WINDOWS/System32/Wbem export TARGET=arm-linux-gnueabihf export PREFIX=/opt/crosstool/gcc-4.9.2-glibc-2.19/$TARGET cd /opt/crosstool/src/build-gdb find . -delete cp -R ../gdb-7.7.1/. . ./configure --prefix=$PREFIX --target=$TARGET --with-expat --with-libexpat-prefix=/usr/local if [ "$?" -ne "0" ]; then echo "=== build script: failed to configure cross-gdb-client ===" exit 1 fi make if [ "$?" -ne "0" ]; then echo "=== build script: failed to make cross-gdb-client ===" exit 1 fi make install if [ "$?" -ne "0" ]; then echo "=== build script: failed to install cross-gdb-client ===" exit 1 fi cd /opt/crosstool/src/build-gdb/gdb/gdbserver export CC=$PREFIX/bin/$TARGET-gcc export LDFLAGS=-static ./configure --host=$TARGET if [ "$?" -ne "0" ]; then echo "=== build script: failed to configure cross-gdb-server ===" exit 1 fi make if [ "$?" -ne "0" ]; then echo "=== build script: failed to make cross-gdb-server ===" exit 1 fi cp ./gdbserver $PREFIX/usr/bin cp ./gdbreplay $PREFIX/usr/bin echo "=== build script: OK ==="
3. Build GDB
- Run C:\MinGW\msys\1.0\opt\crosstool\src\build_cross_toolchain.cmd and wait until it completes.
- Replace TARGET=arm-linux-gnueabihf with TARGET=arm-linux-gnueabi in build_cross_toolchain.sh, then run & wait for build_cross_toolchain.cmd again.
- If there are no errors, shutdown the MinGW VM and make snapshot "SNAP-F".
>> Read next section or
buy already prepared
cross-compiler (€10) to save your time.