How to find what library a symbol is defined in.

  • Permalink
  • submit to reddit
  • Email
  • Follow


I have sometimes been faced with problems when compiling open source
packages that a link step will fail with "undefined symbol" errors.
This is usually a case of a package that compiles as-is under some
other UNIX but fails on Solaris because of packaging differences. A
good example would be a symbol like "gethostname". On Solaris you need
to specify "-lnsl" on the link command the get this resolved but
apparently you don't on other unices.

My question is this. Given a particular symbol name, is there a way to
scan or determine somehow which library, if any, on the system defines
the symbol?

TIA

Jim Lane
0
Reply Jim 11/22/2007 1:46:40 PM

See related articles to this posting


Jim.Lane@cibc.com writes:

> My question is this. Given a particular symbol name, is there a way to
> scan or determine somehow which library, if any, on the system defines
> the symbol?

$ /usr/ccs/bin/nm -Ap /usr/lib/* 2>/dev/null | grep ' gethostbyname$' | grep -v ' U '
/usr/lib/libnsl.a[gethostent.o]: 0000000000 T gethostbyname
/usr/lib/libnsl.so: 0000221468 T gethostbyname
/usr/lib/libnsl.so.1: 0000221468 T gethostbyname
/usr/lib/libxnet.so: 0000000000 T gethostbyname
/usr/lib/libxnet.so.1: 0000000000 T gethostbyname

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
0
Reply Paul 11/22/2007 3:47:49 PM

In <c02dbf2c-1e17-4dc8-b0fe-dd77464da7a1@t47g2000hsc.googlegroups.com> Jim.Lane@cibc.com writes:

>I have sometimes been faced with problems when compiling open source
>packages that a link step will fail with "undefined symbol" errors.
>This is usually a case of a package that compiles as-is under some
>other UNIX but fails on Solaris because of packaging differences. A
>good example would be a symbol like "gethostname". On Solaris you need
>to specify "-lnsl" on the link command the get this resolved but
>apparently you don't on other unices.

>My question is this. Given a particular symbol name, is there a way to
>scan or determine somehow which library, if any, on the system defines
>the symbol?

I usually look at the man page.  It lists both the library names
and the include files needed by the function.  Here's an example:

  NAME
       getsockopt, setsockopt - get and set options on sockets
  
  SYNOPSIS
       cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
       #include <sys/types.h>
       #include <sys/socket.h>

I don't know if there's a database for this purpose.

-- 
-Gary Mills-    -Unix Support-    -U of M Academic Computing and Networking-
0
Reply Gary 11/22/2007 4:01:50 PM

On Nov 22, 5:46 am, Jim.L...@cibc.com wrote:
> I have sometimes been faced with problems when compiling open source
> packages that a link step will fail with "undefined symbol" errors.
> This is usually a case of a package that compiles as-is under some
> other UNIX but fails on Solaris because of packaging differences. A
> good example would be a symbol like "gethostname". On Solaris you need
> to specify "-lnsl" on the link command the get this resolved but
> apparently you don't on other unices.
>
> My question is this. Given a particular symbol name, is there a way to
> scan or determine somehow which library, if any, on the system defines
> the symbol?

Just use "nm" and pipe to awk scanning for ABS but not LOCL or some
type of
shell scripting to isolate what you are looking for. nm being the key.
Maybe theres a more clever way but  its not something you do a lot so
I just scribble something up on the fly when needed.
0
Reply gerryt 11/22/2007 4:25:34 PM

On Nov 22, 10:47 am, Paul Pluzhnikov <ppluzhnikov-...@charter.net>
wrote:
> Jim.L...@cibc.com writes:
> > My question is this. Given a particular symbol name, is there a way to
> > scan or determine somehow which library, if any, on the system defines
> > the symbol?
>
> $ /usr/ccs/bin/nm -Ap /usr/lib/* 2>/dev/null | grep ' gethostbyname$' | grep -v ' U '
> /usr/lib/libnsl.a[gethostent.o]: 0000000000 T gethostbyname
> /usr/lib/libnsl.so: 0000221468 T gethostbyname
> /usr/lib/libnsl.so.1: 0000221468 T gethostbyname
> /usr/lib/libxnet.so: 0000000000 T gethostbyname
> /usr/lib/libxnet.so.1: 0000000000 T gethostbyname
>
> Cheers,
> --
> In order to understand recursion you must first understand recursion.
> Remove /-nsp/ for email.

Interesting. How am I to interpret the result in your example above?
It appears as if gethostbyname is defined in 2 places, libnsl and
libxnet. Which of the 2 should one use? Or does it matter?

-Jim
0
Reply Jim 11/22/2007 6:08:24 PM

On Nov 22, 11:01 am, Gary Mills <mi...@cc.umanitoba.ca> wrote:
> In <c02dbf2c-1e17-4dc8-b0fe-dd77464da...@t47g2000hsc.googlegroups.com> Jim.L...@cibc.com writes:
> >I have sometimes been faced with problems when compiling open source
> >packages that a link step will fail with "undefined symbol" errors.
> >This is usually a case of a package that compiles as-is under some
> >other UNIX but fails on Solaris because of packaging differences. A
> >good example would be a symbol like "gethostname". On Solaris you need
> >to specify "-lnsl" on the link command the get this resolved but
> >apparently you don't on other unices.
> >My question is this. Given a particular symbol name, is there a way to
> >scan or determine somehow which library, if any, on the system defines
> >the symbol?
>
> I usually look at the man page.  It lists both the library names
> and the include files needed by the function.  Here's an example:
>
>   NAME
>        getsockopt, setsockopt - get and set options on sockets
>
>   SYNOPSIS
>        cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
>        #include <sys/types.h>
>        #include <sys/socket.h>
>
> I don't know if there's a database for this purpose.
>
> --
> -Gary Mills-    -Unix Support-    -U of M Academic Computing and Networking-

Well, OK. I'm not sure how general a solution this is. Using a
solution
posted by another user I've discovered the location of another symbol
I'd been having trouble with:

 # /usr/ccs/bin/nm -Ap /usr/lib/* 2>/dev/null | grep ' Malloc$' | grep
-v ' U '
/usr/lib/libmeta.so: 0000199160 T Malloc
/usr/lib/libmeta.so.1: 0000199160 T Malloc

However there seems not to be a man page for Malloc.

-Jim
0
Reply Jim 11/22/2007 6:13:29 PM

Jim.Lane@cibc.com writes:

> On Nov 22, 10:47 am, Paul Pluzhnikov <ppluzhnikov-...@charter.net>
> wrote:
>> Jim.L...@cibc.com writes:
>> > My question is this. Given a particular symbol name, is there a way to
>> > scan or determine somehow which library...

>> /usr/lib/libnsl.a[gethostent.o]: 0000000000 T gethostbyname
>> /usr/lib/libnsl.so: 0000221468 T gethostbyname
>> /usr/lib/libxnet.so: 0000000000 T gethostbyname
>
> Interesting. How am I to interpret the result in your example above?

Exactly as the answer to your question: these are the 3 libraries
that define the symbol that you are looking for.

> It appears as if gethostbyname is defined in 2 places, libnsl and
> libxnet. Which of the 2 should one use? Or does it matter?

That's a different question from the one you originally asked.
You'll have to check what other symbols the libraries define,
use man pages for these other functions, or google a bit, or guess
and try either.

You could also run 'elfdump' on the libraries, and learn more
about them. On my Solaris8 box, I get:

$ elfdump -d /usr/lib/libxnet.so

Dynamic Section:  .dynamic
     index  tag               value
       [0]  SONAME           0x4a9             libxnet.so.1
       [1]  FILTER           0x4b6             libsocket.so.1:libnsl.so.1:libc.so.1
       [2]  HASH             0x74              
       [3]  STRTAB           0xc84             
       [4]  STRSZ            0x4db             
       [5]  SYMTAB           0x4b4             
       [6]  SYMENT           0x10              
       [7]  CHECKSUM         0xf563            
       [8]  VERDEF           0x1160            
       [9]  VERDEFNUM        0x3               
      [10]  FLAGS_1          0x10              [ LOADFILTER ]


So libxnet.so is a filter over libsocket and libnsl.
You can learn more about filter libraries here:

  http://docs.sun.com/app/docs/doc/816-0559/6m71o2afb?a=view#chapter4

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
0
Reply Paul 11/22/2007 9:18:48 PM
comp.unix.solaris 25792 articles. 87 followers. Post

6 Replies
1188 Views

Similar Articles

[PageSpeed] 52


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Where to find symbols in libraries?
I have a basic question about libraries. I am trying to build konqueror embedded, and if I use only the libraries on my embedded system, the build fails because it cannot find inet_pton. The problem is described here: <http://lists.kde.org/?l=konq-e&m=107478562601204&w=2> . The solution is to set up your libs so that configure can find the lib with inet_pton.... So... How do I find out which lib I need? nm returns a whole pile of inet_pton symbols, but I have no idea how to read it. Could someone help me out? Thanks, --Yan CptDondo <yan@NsOeSiPnAeMr.com> wrote ...

Multiply defined symbols in wx libraries
Hi, I am using wxMSW 2.6.1, Win XP. When building my project, I receive the message wxbase26d.lib(log.obj) : error LNK2005: "void __cdecl wxLogDebug(char const *,...)" (?wxLogDebug@@YAXPBDZZ) already defined in wxmsw26_adv.lib(grid.obj) which sounds like a wx library multiple definition. How to cure it? Thanks Janos --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org Sorry for the false alarm. Somehow I used...

What to do with a linker warning about a public symbol from the STL library defined in two modules?
Hello All, I'm getting the following linker warning: (I'm using Borland C++ Builder 6) [Linker Warning] Public symbol '_STL::basic_ostream<char, _STL::char_traits<char> >& _STL::operator << (_STL::basic_ostream<char, _STL::char_traits<char> >&, const signed char *)' defined in both module C:\ROSIEN\MONTIUM\SIMULATOR\MONTIUMSIMUTILITY.OBJ and C:\ROSIEN\HIGH2\BASICSIMULATOR.OBJ I don't understand why this is happening. Obviously this is not a symbol I have defined, it is an STL function. I know I am including <iostream> and oth...

Help: Define a function for association list for finding a symbol's source and destination
How to define a function taht takes an A-list and return the list of elements that appear both as the source and destination in the A-list? For example: (source-dest '((a . b) (b . c) (c .a))) Pls help garynkill wrote: > How to define a function taht takes an A-list and return the list of > elements that appear both as the source and destination in the A-list? > > For example: > (source-dest '((a . b) (b . c) (c .a))) > Pls help Homework problem? -- A. Kanawati NO.antounk.SPAM@comcast.net yes...how to go about solving it....i can't seem to be able to c...

Q: can't find C++ symbols if gcc linking with Sun C++ library
Dear C++ guru, I need to compile C++ server which used a lot of GNU G++ specific codes AND one Sun C++ library g++ -c a_i.cc i=1,...n then g++ a_i.o ... -lSUNLIB_other -lGNULIB_other(s) -o exe Undefined symbol: Cl::Cl(void) Cl::set(int) Cl::~Cl(void) .... So, seems that Sun C++ and G++ differently resolved classes ..... Is it true? Or there are some options here? What can I do? I can't recompile SUNLIB_other under g++, can't GNULIB_other under SUN CC. Best regards, Albert. P.S.: Could you also send your answers to brecht_11@yahoo.com too Albert wrot...

How to find name of shared library within that library
How can I find the name of a .so file (shared library) from code within the file? Here's what I am trying to do: I am writing a shared library to be used by other developers. I would like to be able to checksum the library at startup, to make sure it's not corrupted. (This is a FIPS 140-2 requirement.) Since the function _init() in the library is called automatically whenever an application loads the library, that would seem to be the place to put the checksumming code. But I don't know how to find the full path to the .so file, which I need in order to read and ch...

Symbole referencing errors: symbol is defined multiple times
Hi Bhooshan and all, I�m having a large Vc++-project which contains several C files. My task is to convert these exisiting code to run on a TI C62x. After having done the necessary modi-fications I have problems with the TI Code Composer v3 linker. When I compile the project,I get the following linking error: [Linking...] "C:\CCStudioEval\C6000\cgtools\bin\cl6x" -@"Debug.lkf" <Linking> >> error: symbol _errortext is defined multiple times: Likewise im getting some 450 symbol referencing errors.I don`t understand why the symbols are defined multiple times I...

Question about symbols, slot-exists-p and find-symbol
Hi, I'm looking for some help, I'm trying to access a slot of a CLOS object that has a certain name, coming from a string "name" To make things clearer, why does cg-user(55) in the example work while cg-user(56) doesn't? (defclass arena ()(longname map)) #<STANDARD-CLASS ARENA> CG-USER(54): (defvar sth (make-instance 'arena)) STH CG-USER(55): (slot-exists-p sth 'longname) T CG-USER(56): (slot-exists-p sth (find-symbol "longname" (package-name *package*))) NIL thanks, Greetings, Johan On Fri, 02 Dec 2005 02:21:37 +0100, Jovdbroe <jovdbroe@...

what's differnece between #ifdef symbol and #if defined(symbol)
hi all, is there any shadow between #ifdef symbol and #if defined(symbol)? thanks in advance. baumann@pan "baumann@pan" <baumann.Pan@gmail.com> wrote: > is there any shadow between #ifdef symbol and #if defined(symbol)? Apart from being able to write #if defined(S1) && defined(S2), AFAICT nothing. Richard ...

Symbols in library.
I got some question about symbols in libraries ... In libraries, there is public symbols and "not public" symbols (private, static)... In C when we use the "static" keyword on the declaration of a function, the function is not public in the library. 1- When I use a class, all is symbols are put in the public section of the library. How can I change that. The keyword "private" in a class is only for the langage or does it change (like "static") something in libs ? Even in object file ? 2- Even symbols which are not "static" have there decorat...

Defining a symbol
I need to define a symbol. The size of the symbol (the =93box=94 it is in) must be the same as the size of \top. It should consist of a small \top in the upper left corner and a small \times in the lower right corner, like this: T X I would appreciate it very much if someone could tell me how to do that. Best regards Casper Casper Storm Hansen <casper_storm_hansen@hotmail.com> wrote: > I need to define a symbol. The size of the symbol (the �box� it is in) > must be the same as the size of \top. It should consist of a small > \top in the upper left corner ...

Where to find libraries?
Im new to Java and google doesnt give a "final answer." Which is the best site for browsing Java libraries? I am specifically looking for a library to open,edit and check pixelcolors of images. One for videos would be good too. On Fri, 4 Jul 2008 14:12:15 -0700 (PDT), ssecorp <circularfunc@gmail.com> wrote, quoted or indirectly quoted someone who said : >Which is the best site for browsing Java libraries? your own computer. Download and install the documentation. Then use a program like Copernic to index and search it for you. See http://mindprod.com/jgloss/copernic...

cannot find symbol?
Hi, I am trying to create an abstract class with their particular implementations for the different decompress formats java supports (I know it works. I have done it before), but I am getting some uncomprehensible "cannot find symbol" error, even though I did compile the implementation classes first and I am making them accessible through the classpath What does this error mean in this case? How can I fix it? lbrtchx sh-3.1# javac -cp ./activation.jar:./tar.jar:. ReadInFls00Test.java ReadInFls00Test.java:9: cannot find symbol symbol : class Unzip00 location: class ReadInFl...

(Encryption Package) error: cannot find symbol symbol: class BaseNCode
When I include the below package (link 1) in a project, I get the following error message: C:\...\src\org\apache\commons\codec\binary\Base64.java:50: error: cannot find symbol public class Base64 extends BaseNCodec { symbol: class BaseNCode The code in (1) came from (2). I'd like to use both of these. What am I doing wrong here! What should I be doing. (Do I need a dot jar for this.) How do I encrypt strings. Also, do you have a simple example project. Is there a better alternative to this package for encryption. What should I be considering Many Thanks, (L...

Symbol library
Please confirm this for me and then I will send it in. Start a new drawing in SW SP3.0 (2.1 & 2005 Beta both work ok.) Put in a note, dimension, weld - anything that uses a symbol library, like centerline, fillet weld, etc. As long as the first library you pick is Modifying Symbols, you can then pick another library. But then after that, the box in which to pick another library is grayed out. Also, if you pick a library other than Modifying Symbols as your first, you then have no other choices. It doesn't seem to matter what you use the symbol for, just the fact that you don't...

cannot find symbol
New to java. I have a snippet of code that I can compile fine on a FreeBSD box running 1.1.4, or something similar: FileInputStream fs = new FileInputStream(f); InputStreamReader sirLine; BufferedReader fileInput; sirLine = new InputStreamReader(fs); fileInput = new BufferedReader(sirLine); while ( j <= 53 ) { fileline = fileInput.readLine(); I just installed NetBeans 5.0 on WinXP as my FreeBSD box isn't portable. I loaded the source files and now I get an error for the first line that says: unreported excpeption java.io.FileNotFoundException; must be caught or declared to...

Find libraries
I have been asked to make a project which contains port programming.C Builder is the program i choose to work with. I would like to use function "outportb()" but i can't because the corresponding library does not exist.So I would like to find that library but i don't know how! The header file that "outportb()" function uses is "dos.h". Which is the corresponding library??? I 'll would be gratefull if you could answer my question. It's very important to me! Thank You On 5 Apr 2006 15:29:21 -0700, viantina@yahoo.com wrote in comp.programming: ...

finding libraries
Is this the correct way to do this. ls -R | grep lib > locate I am inside a directory and have decompressed a file. I now want to find the libraries in the file and check the whole computer system to be sure I do not overwrite something. TIA Dave On Thu, 28 Sep 2006 00:54:41 +0000, Dave Kelly wrote: > Is this the correct way to do this. > > > ls -R | grep lib > locate > > I am inside a directory and have decompressed a file. I now want to find > the libraries in the file and check the whole computer system to be sure > I do not overwrite something. &g...

Cannot find symbol
Hello, When I write the following test package the compile fails due to not being able to find the symbol. So, I assume that it's not able to find the Contructor TimedBufferedReader which exists within my com.webrezpro.lib Library. Any ideas on why this would be the case? The exact error is below, along with a uncompilable test package. (Remove the TimedBufferReader calls and it will compile fine) The constructor for TimedBufferedReader (extends BufferedReader) within the com.webrezpro.lib is: /** * TimedBufferedReader constructor. * @param in Reader */ TimedBufferedReader(...

DEFINER library?
I found the definer page on common-lisp.net and I am a bit at loss. It's all really neatly described here: http://common-lisp.net/project/definer/ and it looks absolutely gorgeous, but where can I get that thing? More importantly: Why is this not available via quicklisp? Is there any known reason not to use it? Antsan <thomas.bartscher@gmail.com> writes: > I found the definer page on common-lisp.net and I am a bit at loss. > It's all really neatly described here: http://common-lisp.net/project/definer/ > and it looks absolutely gorgeous, but where can I get ...

Symbols Libraries
I'm looking for mechanical symbols. In particular fasteners. Anyone have an idea of where to find free mechanical symbol libraries. Carl Check out my AutoCAD Links Page at http://www.cadalot.co.uk Also get in touch with suppliers like Hilti Lindaptor etc. etc. Regards Alan On Sat, 9 Aug 2003 22:26:05 -0700, "Carl Backstrom" <wheelncarl@yahoo.com> wrote: >I'm looking for mechanical symbols. In particular fasteners. Anyone have an >idea of where to find free mechanical symbol libraries. > >Carl > You may want to check o...

Symbol library
Hi. I am trying to make my own symbol library (in Corel Draw 12), but even I make objects, convert them to symbols and export this library, I cannot use them anywhere else. They are visible in the library, but cannot be dragged to the stage. Where am I wrong? Thank you for any help. Imagino ...

2nd module cannot find symbols in first module -help please
Hi all vxworks 5.4 on windows I have module A which i can download to the box. I then have module B which Module A downloads from the network. Now module A can load/find symbols from module B. However, module B cannot find the symbols which it needs from module A. I get the following when module A loads B: (i have changed the func names) Undefined symbol: function1 (binding 1 type 0) Undefined symbol: function2(binding 1 type 0) Undefined symbol: function3(binding 1 type 0) Undefined symbol: function4(binding 1 type 0) Undefined symbol: function5(binding 1 type 0) Undefined symbol:...

[tao-users] Symbol referencing errors (Too many referenced symbols are not defined)
------=_Part_499_23499149.1142489593433 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, all When I use "tao_idl -Ge 2", the compiling is completed successfully but an annoying problem arises during linking. The cc compiler casts many errors as below. ///////////////////////////////////////////////////////////////////////////= /////////////////// Undefined first referenced symbol in file CORBA::OctetSeq*TAO_ServerRequestInfo::adapter_id(COR...