From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13610 invoked by alias); 27 Feb 2008 03:16:48 -0000 Received: (qmail 13601 invoked by uid 22791); 27 Feb 2008 03:16:47 -0000 X-Spam-Check-By: sourceware.org Received: from hs-out-0708.google.com (HELO hs-out-0708.google.com) (64.233.178.240) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 27 Feb 2008 03:16:22 +0000 Received: by hs-out-0708.google.com with SMTP id 4so2094275hsl.8 for ; Tue, 26 Feb 2008 19:16:20 -0800 (PST) Received: by 10.100.41.16 with SMTP id o16mr11242856ano.90.1204082179448; Tue, 26 Feb 2008 19:16:19 -0800 (PST) Received: by 10.100.14.19 with HTTP; Tue, 26 Feb 2008 19:16:19 -0800 (PST) Message-ID: Date: Wed, 27 Feb 2008 03:24:00 -0000 From: "Robert Bu" To: robert.bu@gmail.com, gdb@sourceware.org Subject: Re: How to set the path of shared library in Linux MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00227.txt.bz2 -----Original Message----- From: Daniel Jacobowitz Sent: 2008-02-27 10:29 > On Wed, Feb 27, 2008 at 10:22:13AM +0800, Robert Bu wrote: >> Hello, >> >> How can I set the search path of the shared libraries in Linux for GDB? >> I tried "set solib-search-path path_to_my_shared_lib", but GDB still >> tries the $LD_LIBRARY_PATH first. I have two versions of the same shared >> library, one is in $LD_LIBRARY_PATH, the other is in >> path_to_my_shared_libray ( not in $LD_LIBRARY_PATH). GDB just always >> uses the one in $LD_LIBRARY_PATH. > > I'm assuming you are doing local, native debugging (that is, "run"). > > GDB should load symbols for whichever one your program is actually > using. A common problem is that GDB uses a shell to start your > program; check that it isn't changing the search paths. If GDB > is not loading the same one the program is using, please show us a > complete transcript of the debug session. > Thank you for your immediate response. Yes, I'm doing native debugging. And the GDB version is 6.7.1. Below is the debug session: GNU gdb 6.7.1 Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"... Using host libthread_db library "/lib/tls/libthread_db.so.1". (gdb) r Starting program: /home/robert_bu/local/rlxvm_static_gcc323/bin/engine -c platform/others/rlxvm_config_lance.h /home/robert_bu/local/rlxvm_static_gcc323/bin/engine: relocation error: /home/STools/RLX/scv-1.0p2-sysc-2.2.0-gcc-3.2.3/lib-linux/libscv.so: undefined symbol: _ZN5sc_dt14convert_to_fmtERKSsNS_9sc_numrepEb Program exited with code 0177. (gdb) show solib-search-path The search path for loading non-absolute shared library symbol files is . (gdb) set solib-search-path /home/robert_bu/local/rlxvm_static_gcc323/lib (gdb) r Starting program: /home/robert_bu/local/rlxvm_static_gcc323/bin/engine -c platform/others/rlxvm_config_lance.h /home/robert_bu/local/rlxvm_static_gcc323/bin/engine: relocation error: /home/STools/RLX/scv-1.0p2-sysc-2.2.0-gcc-3.2.3/lib-linux/libscv.so: undefined symbol: _ZN5sc_dt14convert_to_fmtERKSsNS_9sc_numrepEb Program exited with code 0177. (gdb) shell ls /home/robert_bu/local/rlxvm_static_gcc323/lib librlxvm.a librlxvm.la* libscv.so* (gdb) As you can see GDB always tries "/home/STools/RLX/scv-1.0p2-sysc-2.2.0-gcc-3.2.3/lib-linux/" instead of using "/home/robert_bu/local/rlxvm_static_gcc323/lib" as I set. However, If I set this path to LD_LIBRARY_PATH, GDB can find it successfully.