Supported on windows
Supported on linux
Not supported on embedded
Supported on android

set solib-search-path command

Specifies directories where GDB will search for shared libraries with symbols. This option is useful when debugging with gdbserver.


set solib-search-path [Directories]
show solib-search-path


Specifies the list of directories separated by colon (:) on Linux or semicolon (;) on Windows where GDB will look for shared libraries when searching for symbols.

Typical use

This command is useful when debugging remote programs via gdbserver. If the shared library path on the remote computer and the GDB computer is different, GDB won't automatically find the local copy of the library and load its symbols unless the directory containing it is specified in set solib-search-path.

E.g. if you have copied /home/testuser/libtest/ on the computer with GDB to /tmp/ on the computer with GDBServer, you will need to specify set solib-search-path /home/testuser/libtest in order to get the symbols loaded.

Default value

The default value for the solib-search-path variable is "." that corresponds to the working directory of GDB (directory where GDB was launched unless changed using the cd command).


In this example we will debug a simple shared library with gdbserver:

#include <stdio.h>

int func()
    printf("In func()\n");
    return 0;

We will use a simple program to test our library:

#include <stdio.h>

int func();

int main()
    printf("In main()\n");
    return 0;

First, we build the application and the library and deploy it to another machine:

cd /home/testuser/libtest
g++ -ggdb -fPIC -shared lib.cpp -o
g++ -ggdb main.cpp -o testApp -Wl,--rpath='$ORIGIN'
scp testApp deploy_machine:/tmp

Then we run gdbserver on the deploy_machine machine:

cd /tmp
gdbserver :2000 testApp

Finally we run GDB from a different directory (otherwise it will still find

cd /
gdb /home/testuser/libtest/testApp

Now we will try to set a breakpoint inside (that will fail as /tmp/ is not initially loaded). Note how specifying set solib-search-path allows GDB load the symbols and set a breakpoint:

(gdb) target remote deploy_machine:2000
Remote debugging using deploy_machine:2000
Reading symbols from /lib/
Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/
Loaded symbols for /lib/
(gdb) break main
Breakpoint 1 at 0x80484ed: file main.cpp, line 7.
(gdb) continue
Breakpoint 1, main () at main.cpp:7
7 printf("In main()\n");
(gdb) break test
Function "test" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) info sharedlibrary
warning: Could not load shared library symbols for /tmp/
Do you need "set solib-search-path" or "set sysroot"?
From To Syms Read Shared Object Library
0x0019b820 0x001b3b9f Yes /lib/
No /tmp/
0x004bcf10 0x005f15cc No /lib/i386-linux-gnu/
(gdb) set solib-search-path /home/testuser/libtest
Reading symbols from /home/testuser/libtest/
Loaded symbols for /home/testuser/libtest/
Reading symbols from /lib/i386-linux-gnu/
Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/
Loaded symbols for /lib/i386-linux-gnu/
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x0019b820 0x001b3b9f Yes /lib/
0x00f893a0 0x00f894c8 Yes /home/testuser/libtest/
0x004bcf10 0x005f15cc Yes /lib/i386-linux-gnu/
(gdb) break func
Breakpoint 2 at 0xf8946e: file lib.cpp, line 5.
(gdb) continue

Breakpoint 2, func () at lib.cpp:5
5 printf("In func()\n");
(gdb) backtrace
#0 func () at lib.cpp:5
#1 0x080484fe in main () at main.cpp:8

Compatibility with VisualGDB

VisualGDB automatically configures search paths using the set solib-search-path command when you debug your Linux or Android projects with Visual Studio. Nonetheless you can issue the command manually as well using the GDB Session window.

See also