Mark
Mark

Reputation: 5050

How to set sysroot for GDB

Scenario

Dev machine running Ubuntu 20.04 and QtCreator. Qt libs are installed to /home/mark/Qt/6.2.0/gcc_64/lib.

Target machine running Ubuntu 20.04. Qt libs are installed to /home/user/Qt/6.2.0/gcc_64/lib.

Issue

When debugging a remote application from QtCreator I get:

Could not load shared library symbols for 8 libraries, e.g. /home/user/Qt/6.2.0/gcc_64/lib/libQt6Gui.so.6.

Use the "info sharedlibrary" command to see the complete listing.

Do you need "set solib-search-path" or "set sysroot"?

Setup

In Tools > Options > Debugger > GDB > Additional Startup Commands I wrote:

set sysroot /home/user/Qt/6.2.0/gcc_64/
set solib-search-path /home/user/Qt/6.2.0/gcc_64/

Questions

  1. I read somewhere that to speed up the debugging I need to set sysroot to the local libraries (i.e. /home/mark/... instead of /home/user/...). Which is the correct path?

  2. Is it correct to set sysroot to the parent directory of the lib folder that contains the Qt libraries?

  3. where should I run the info sharedlibrary command?

Upvotes: 2

Views: 10487

Answers (1)

Employed Russian
Employed Russian

Reputation: 213696

Which is the correct path?

The one where libraries can be found during debugging, i.e. the path on the development machine.

Is it correct to set sysroot

The sysroot should be used when you have a complete set of target libraries (including all system ones).

That is, if you had the complete mirror of target libraries under e.g. /home/mark/target/, then you would use set sysroot /home/mark/target.

Since you don't have such a directory, you should not use sysroot at all.

Instead, you should tell GDB that it can find libraries in /home/mark/Qt/6.2.0/gcc_64/lib with set solib-search-path /home/mark/Qt/6.2.0/gcc_64/lib.

where should I run the info sharedlibrary command?

At the (gdb) prompt.

Upvotes: 3

Related Questions