0

I'm trying to cross compile a version of GDB server from source for the MIPS32 architecture. I'm using an x86_64 machine.

I'm using the Buildroot uClibc compiler for MIPS (mips-buildroot-linux-uclibc-gcc).

From the GDB server directory I run the ./configure command:

./configure --host=mips-buildroot-linux-uclibc AR=${CROSS}ar LD=${CROSS}ld CC=${CROSS}gcc CXX=${CROSS}g++ RANLIB=${CROSS}ranlib LIBS=-L/root/Desktop/buildroot/buildroot-2018.02.2/output/host/lib

With $CROSS having the value mips-buildroot-linux-uclibc-

./configure runs but I noticed in the output it mentions checking whether we are cross compiling... no. It doesn't seem like ./configure is picking up that I'm trying to cross compile.

I then run make LDFLAGS=-static which produces the error:

ld: cannot find -lthread_db
collect2: error: ld returned 1 exit status
Makefile:379: recipe for target 'gdbserver' failed
make: *** [gdbserver] Error 1

I read that you can remove the lthread_db dependencies in the GDB server makefile however I need to debug threaded applications.

How can I cross compile GDB server for the MIPS32 architecture using the Buildroot cross compilation tool set?

2
  • Are you sure that the --host option of the configure script is not your host PC? May 9, 2018 at 15:48
  • @RenaudPacalet no, that's --build. However, @CS-Student, you should pass --target=mips-buildroot-linux-uclibc as well. That should fix your checking whether we are cross compiling... problem.
    – Arnout
    May 10, 2018 at 11:08

1 Answer 1

1

Since you anyway build the toolchain with Buildroot, the easiest is to also build gdbserver with Buildroot.

  • Make sure you have Thread library debugging (BR2_PTHREAD_DEBUG) enabled in the toolchain menu.
  • Select gdb from Target packages -> Debugging. gdbserver is then selected by default. You don't need full gdb.
  • You apparently want a static executable, so select Static only from Build options -> libraries.

This should give you a statically linked gdbserver executable.

Note that if you change the toolchain options (Thread library debugging, static libraries), you have to do a full rebuild with make clean; make.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.