Building Cross-GDB in the MinGW VM
You need to build Cross-GDB to debug remotely by running a gdb server on the Linux PC and controlling debug session using Eclipse on Windows.
1. Prepare to build GDB
Assign the following contents to the C:\MinGW\msys\1.0\opt\crosstool\src\build_gcc_cross.sh:
#!/bin/bash export PATH=.:/usr/local/bin:/mingw/bin:/bin export PATH=$PATH:/c/WINDOWS/system32:/c/WINDOWS export PATH=$PATH:/c/WINDOWS/System32/Wbem export TARGET=i586-linux-gnu export PREFIX=/opt/crosstool/gcc-8.3.0-glibc-2.28/$TARGET cd /opt/crosstool/src/build-gdb find . -delete cp -R ../gdb-8.2.1/. . LDFLAGS="-Wl,-s -Wl,-static -static -static-libgcc" \ ./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 find . -delete cp -R ../gdb-8.2.1/. . cd gdb/gdbserver export CC=$PREFIX/bin/$TARGET-gcc export CXX=$PREFIX/bin/$TARGET-g++ export AR=$PREFIX/bin/$TARGET-ar export RANLIB=$PREFIX/bin/$TARGET-ranlib ./configure --host=$TARGET --target=$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 cp ./libinproctrace.so $PREFIX/usr/lib echo "=== build script: OK ==="
2. Build GDB
- Run C:\MinGW\msys\1.0\opt\crosstool\src\build_gcc_cross.cmd and wait until it completes.
- Replace TARGET=i586-linux-gnu with TARGET=x86_64-linux-gnu in build_gcc_cross.sh, then run & wait for build_gcc_cross.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.