How to find what library a symbol is defined in.

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
Jim
11/22/2007 1:46:40 PM
comp.unix.solaris 25868 articles. 89 followers. Post Follow

6 Replies
1355 Views

Similar Articles

[PageSpeed] 38
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
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
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
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
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
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
Paul
11/22/2007 9:18:48 PM
Reply:
Similar Artilces:

Huh??? No image handler for type 15 defined?
I am trying to load a small PNG image file as follows: wxImage image; image.LoadFile (wxT("bitmaps/new.png"), wxBITMAP_TYPE_PNG); But instead I get: "Warning: No image handler for type 15 defined." This is on Windows (wxMSW). I compiled the library with PNG, ZLIB, TIFF, JPEG, etc. support (or so I believe?) How is it possible that a handler for PNG cannot be found? Thanks, Pam ===== WX : 2.4.2 OS : Windows 2000 COMPILER: VC++ 6 (IDE) __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it!...

Find and Grep together
Hi All, I am sorry if this is not the right group for this question. I am using find and grep together to find a string in a file from the top level directories. find . -name "*.c" -exec grep "string" {} \; -print | more. | \/ top level directorie I am sure that the string I am searching is in the lower directories where I am searching but this command is unable to find the string which I am looking. Can anyone please help me. My version control tool is clear case and my config spec also supports all the files....

Presets Library
Hey people! Can anyone help? I need the original library of presets for lightwave [8]. I will trade for something if anyone has them. I have a copy of Lightwave [8] 1001 Tips & Tricks in e-format if anyone wants a copy. Thanks > Can anyone help? I need the original library of presets for lightwave [8]. I have a surplus LW8 Commercial License with disks and duo USB dongle that I will probably be selling in the near future if that's any help. Otherwise, contact your Newtek Reseller or Newtek direct to get a replacement installation disk if your original has become corrupt ...

How to find out the current version of the MySQL installation ?
How to find out (from the command line under Linux) the current version of the MySQL installation ? Or is there a config file which contains the version number ? Werner Werner Sammer <wersam@yahoo.de> wrote: > How to find out (from the command line under Linux) > the current version of the MySQL installation ? > Or is there a config file which contains the version number ? > Werner Command line: mysql --version Regards, Johan -- _____________________________________ Ing. Johan van Oostrum chaos geordend - www.chaosgeordend.nl _____________________________________ >...

finding max
Hello all I have a matrix a = 1 2 3 4 5 6 7 8 9 10 11 12 now I call max(a) ans = 9 10 11 12 to find the max, I have to call max(max(a)) Is there any way I can get the max of a matrix in one command? Thanks sore wrote: > > Hello all > > I have a matrix > > a = > > 1 2 3 4 > 5 6 7 8 > 9 10 11 12 > > now I call > > max(a) > > ans = > > 9 10 11 12 > > to find the max, I have to call max(max(a)) > > Is there any way I can get the max of a matrix > in one command? >...

Find it all
Find it all http://asb-comm-logicx.net/ ...

Narrowed down bottlneck to disk, how can I find out which FS is being hammered? 100% utilization
In my process of drilling down to get to the bottom of our performance issues, I am seeing huge I/O wait on a particular disk. What tools are available to dig deeper, find out which file system is hammering the disk and/or which processes are hogging the CPUS? We are talking 100% utilization here: mpstat output: CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl 0 199 0 259 12 2 176 9 22 30 0 1882 11 6 83 0 1 205 0 259 204 194 176 8 23 34 0 1801 11 5 84 0 2 203 0 289 34 23 176 7 23 31 ...

Complicated Find Expression
Hi, I am having problems with my find expression. Basically I want to find to find all files that are _not_ in a test directory and then execute a grep statement on them. The result of that grep statement is further refined by another grep. Finally I would like to echo the result. My grep expression on works fine by itself. The problem is with the find integration. Here is my expression, followed by the output. Thanks for any suggestions/pointers, Mike find ./ -path '*test*' -prune -o -print -exec "grep -PRi 'out.print.*?[^/][^/].*?the' {} | grep -Pi 'out...

[ace-users] Can't find ACEd.dll
This is a multi-part message in MIME format. ------_=_NextPart_001_01C7A8F9.1452B078 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi=20 =20 ACE VERSION: 5.5.8 =20 HOST MACHINE and OPERATING SYSTEM: Win XP=20 If on Windows based OS's, which version of WINSOCK do you use?: don't know =20 TARGET MACHINE and OPERATING SYSTEM, if different from HOST: COMPILER NAME AND VERSION (AND PATCHLEVEL): =20 THE $ACE_ROOT/ace/config.h FILE [if you use a link to a platform- specific f...

Tektronix PLS-200 (Exabyte EXB-480) Robotic Tape Library System
This is a multi-part message in MIME format. ------=_NextPart_000_00E0_01C48088.299429E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Tektronix PLS200=20 =20 Tape Library System=20 =20 includes: (4) 8mm cartridge tape transports. (80) 8mm data = cartridges: 20GB each for 1.6TB of storage. Access time less than 10 = seconds 110 hours of storage at 24MB/S.=20 =20 1 unit available=20 Local / Overseas Buyer Transaction Welcome. Tektronix PLS200 equipment has been inspected and is in very...

ow-find without sun 'find' key
I've just moved over to a windows platform from solaris and have installed the windows version of xemacs 21.4. I'm having severe withdrawal symptoms from the loss of the sun 'find' key. So to correct this I would like to bind the M-s key combo to the ow-find function and M-S-s to the ow-find-backward function. I have 2 problems trying to achieve this. 1. I have sucessfully bound the M-s keys to the 'ow-find function using the following code in the init.el file. (define-key global-map [(meta ?s)] 'ow-find) However when I execute the function it returns the follo...

I need to find the rows that exist in one table but not in the other with condition
I need to find the rows that exist in one table but not in the other with this condition: (prod_name exist in table1 and not in table2.prod_name ) AND (prod_name exist in table1 and not in table2.'S'+prod_name ) explanation: i want to know if the product not exit and if the combination of the charachter "S" with the product Name also not exist at the other table B.R yuvi SELECT prod_name FROM table1 as A WHERE NOT EXISTS (select * from table2 as B where A.prod_name = B.prod_name) AND NOT EXISTS (select * from table2 as C where A....

find breakpoint programmatically
Hi All, &nbsp; I accidentally posted this question in the special interest forum by mistake so sorry for the duplicate post but i thought it might never get read over there. <a href="http://forums.ni.com/ni/board/message?board.id=BreakPoint&amp;message.id=4162" target="_blank">http://forums.ni.com/ni/board/message?board.id=BreakPoint&amp;message.id=4162</a> &nbsp; Hi all, &nbsp; I was wondering if there is a way to search the vi hierachy for breakpoints programmatically?&nbsp; Why you may ask? &nbsp; I have a piece of code that take...

Find File Attributes
Hello, As a part of my application,I need to compare files generated everyday.I need not need to compare the file contents.I just need to compare the file size,the line count.The files are named in the format,Hyyyymmdd,H denoting History. At present,I use the Dir function to search for the physical existence of the file and I use the debug.print for functions such as filelen(path),GetAttr() etc. My question is how would I put this as a module so that I can use a date function to compare files generated today with that of yesterday (mondays files to be compared against fridays). Also is it pos...

Can't load library "/usr/lib/libcore.a", because load ENOENT on shared library(s)
When I issue call sqlj.install_jar('file:///f:/jars/mail.jar','MAIL'); I get the messages SQL4301N Java or .NET interpreter startup or communication failed, reason code "2". SQLSTATE=58004 2005-10-11-15.31.15.558066+600 I2352539C331 LEVEL: Warning PID : 950280 TID : 1 PROC : db2fmp INSTANCE: db2inst1 NODE : 000 FUNCTION: DB2 UDB, oper system services, sqloJVMvfprintf, probe:20 MESSAGE : Can't load library "/usr/lib/libcore.a", because load ENOENT on shared library(s) 2005-1...

Re: Find unique records and recode
data one; input old $; cards; 5269-7c 5269-8c 5269-8c 5269-3z 5222-7z 5222-7z 5222-7z ; data two; set one; by old notsorted; new + first.old; run; On Mon, 5 Sep 2005 07:24:43 -0700, tortoise <cychen9@GMAIL.COM> wrote: >Hi, >I have one character variable (old). >There are many combinations of "old" variable. >How could I find unique and recode those data to "new"????? > > old new >5269-7c 1 >5269-8c 2 >5269-8c 2 >5269-3z 3 >5222-7z 4 >5222-7z 4 >5222-7z ...

How to find out memory leak?
Hi, all! I'm having memory leak problem with my program, but can't find where's the leak. I have a program written in pure-Ruby. It implemented a Chinese word segment algorithm. I call `segment(text)' to get the result. But each time I call `segment', the memory usage of my program (Ruby) increased several handred K- bytes -- the number of bytes of increment is roughly equal during each call. I can see from outside (using `ps' or `top') that the memory is leaking. But I can't find where the leaking goes. I tried to use ObjectSpace.each_object to find out what ...

pro/piping tutorials
Hello, does anyone know where I could find tutorials about pro/E module: pro/ piping? I would really appreciate any info on this. Thanks a lot! This is a multi-part message in MIME format. ------=_NextPart_000_0033_01C79EE3.B10443C0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable <dugave_11@yahoo.com> wrote in message = news:1180099763.016860.34260@o5g2000hsb.googlegroups.com... Hello, does anyone know where I could find tutorials about pro/E module: pro/ piping? I would really appreciate any info on ...

Help finding AIO w/Fax
I looking for an All In One with FAX (flatbed scanner) for less than $200. I have only been able to fine these two: Canon MP390 and HP Officejet 5510. I do not see any that are Epson, Dell, Ricoh or Samsung. I have ruled out Visioneer and Lexmark because of bad reviews. Does anyone know of any other they recommend. Thanks in advance for your help, Bill ...

help
I received an Excel data file that contains a "+/-" symbol (html code \&plu= smn; &plusmn;), that can be copied and displayed in Word, Notepad, "Kompoze= r" html editor, unix vi, pico editors, and load to/retrieve from MySQL oper= ated on linux. But when I need to manipulate the data in perl, I am lost a= s how to recognize the symbol with RE. Could anyone help? Thanks in advance! joe On 2012-12-15 07:19, Joe wrote: > I received an Excel data file that contains a "+/-" symbol (html code \&plusmn; &plusmn;), that can be copied and...

find.find
import fnmatch, os def find(pattern, startdir=os.curdir): matches = [] os.path.walk(startdir, findvisitor, (matches, pattern)) matches.sort() return matches def findvisitor((matches, pattern), thisdir, nameshere): # for name in nameshere: if fnmatch.fnmatch(name, pattern): fullpath = os.path.join(thisdir, name) matches.append(fullpath) can someone explain why (matches, pattern) is doing in this two funct? thanks In <eo15uq$hna$1@ss408.t-com.hr>, Gigs_ wrote: > import fnmatch, os > > def find(pattern, startdir=os...

find opened classes
Is there any way I can find all the classes that have been re-opened in a project? On 8/21/07, nraychaudhuri@gmail.com <nraychaudhuri@gmail.com> wrote: > Is there any way I can find all the classes that have been re-opened > in a project? > > > No fool proof way. Are there particular changes to a class you are looking to track? For instance you can override method_added to see if anyone adds any additional methods. nraychaudhuri@gmail.com wrote: > Is there any way I can find all the classes that have been re-opened > in a project? > If you don't mind ha...

Image Creation Without GD Library
Greetings, My hosting provider does not support GD libraries yet. I want to generate simple graphics on-the-fly. Anyone have a working sample of "text-to-graphic" code that does not rely on the GD libraries? Thanks! Jerry On Mon, 07 Jul 2003 20:00:18 +0000, Nobody wrote: > Greetings, > > My hosting provider does not support GD libraries yet. I want to generate > simple graphics on-the-fly. Anyone have a working sample of > "text-to-graphic" code that does not rely on the GD libraries? > > Thanks! > Jerry You'll need *some* sort of im...

SW2006 SP3.0 PDF weld symbol
This must be my (un)lucky day. 1. Start a drawing. 2. Put a weld symbol in it that at least has a symbol on the bottom (arrow side.) 3. Save as a PDF. Go look at the PDF file - the weld symbol has flipped the arrow side symbol to the top. Works fine on SW2006 SP2.0 with the BlueBeam PDF. Anyone confirm this? WT Confirm here on sp3.1 Same problem here SW2006 SP3.0. This is bad. We release everything as PDF. Bill Wayne Tiffany wrote: > This must be my (un)lucky day. > > 1. Start a drawing. > > 2. Put a weld symbol in it that at least has a symbol on the bottom...

Where can I find more information about "Gatekeeper"?
Where can I find more information about "Gatekeeper"? Which mentioned in this article? http://www.onjava.com/lpt/a/4173 Have do a quick search at google but get nothing really related. ...