# DL: Array of symbols in a dynamic lib

**URL:** <https://www.ruby-forum.com/t/dl-array-of-symbols-in-a-dynamic-lib/61702>\
**Category:** Ruby\
**Created:** [May 26, 2006, 9:11am UTC](https://www.ruby-forum.com/t/dl-array-of-symbols-in-a-dynamic-lib/61702 "2006-05-26T09:11:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjohn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@Benjohn\_B](https://www.ruby-forum.com/u/Benjohn_B)\
**Post date:** [May 26, 2006, 9:11am UTC](https://www.ruby-forum.com/t/dl-array-of-symbols-in-a-dynamic-lib/61702/1 "2006-05-26T09:11:34Z")

</div>

With DL, is there a way to ask for the symbols that exist within a  
module that I’ve loaded?

For instance, once I’ve done…

```
module_handle = DL::dlopen('my_lib')

```

Can I then ask module\_handle for an array of symbols? I can’t see a  
likely looking method in there, and it seems like it’d be very nice  
to have that kind of introspection available.

Off topic, can someone give me a good entry point for OS X’s tool  
chain for looking inside dynamic libraries, and understanding the  
subject in general? I really found myself struggling! The only really  
constructive thing I found out last night was that on OS X, you need  
to ask cgg to make you:  
-dynamiclib

This let me try an example out (which worked, wooO!), but I’ve no  
idea where these things are usually kept (somewhere in bundles?). Or  
how I can peek about in one.

Cheers,  
Benjohn

---

<div class="post-metadata">

**Author:** ![Benjohn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@Benjohn\_B](https://www.ruby-forum.com/u/Benjohn_B)\
**Post date:** [May 26, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/dl-array-of-symbols-in-a-dynamic-lib/61702/2 "2006-05-26T16:26:36Z")

</div>

On Fri, 26 May 2006, Benjohn B. wrote:

> Cheers,  
> Benjohn

it’s not exactly what you’re asking, but try

strings libname.so

on the command line.

another useful command is

ldd libname.so

also

man ld.so

hth.

-a

---

<div class="post-metadata">

**Author:** ![Benjohn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@Benjohn\_B](https://www.ruby-forum.com/u/Benjohn_B)\
**Post date:** [May 26, 2006, 4:55pm UTC](https://www.ruby-forum.com/t/dl-array-of-symbols-in-a-dynamic-lib/61702/3 "2006-05-26T16:55:24Z")

</div>

On Fri, 26 May 2006, Gregory S. wrote:

> } ldd libname.so  
> }  
> } also  
> }  
> } man ld.so
> 
> Actually, /usr/bin/nm is probably a better bet than any of these.

indeed. i’m still drinking my coffee! 😉

-a

---

<div class="post-metadata">

**Author:** ![Benjohn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@Benjohn\_B](https://www.ruby-forum.com/u/Benjohn_B)\
**Post date:** [May 26, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/dl-array-of-symbols-in-a-dynamic-lib/61702/4 "2006-05-26T16:49:00Z")

</div>

On Fri, May 26, 2006 at 11:24:15PM +0900, removed\_email\_address@domain.invalid wrote:  
[…]  
} it’s not exactly what you’re asking, but try  
}  
} strings libname.so  
}  
} on the command line.  
}  
} another useful command is  
}  
} ldd libname.so  
}  
} also  
}  
} man ld.so

Actually, /usr/bin/nm is probably a better bet than any of these.

} hth.  
} -a  
–Greg

---

<div class="post-metadata">

**Author:** ![Benjohn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@Benjohn\_B](https://www.ruby-forum.com/u/Benjohn_B)\
**Post date:** [May 27, 2006, 1:02am UTC](https://www.ruby-forum.com/t/dl-array-of-symbols-in-a-dynamic-lib/61702/5 "2006-05-27T01:02:30Z")

</div>

On 26 May 2006, at 15:53, removed\_email\_address@domain.invalid wrote:

> > }  
> > indeed. i’m still drinking my coffee! 😉  
> > Brilliant 🙂 Thanks Ara and Greg - they look good.

---

<div class="post-metadata">

**Author:** ![Benjohn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@Benjohn\_B](https://www.ruby-forum.com/u/Benjohn_B)\
**Post date:** [May 27, 2006, 1:11am UTC](https://www.ruby-forum.com/t/dl-array-of-symbols-in-a-dynamic-lib/61702/6 "2006-05-27T01:11:57Z")

</div>

On 26 May 2006, at 23:59, Benjohn B. wrote:

> > > } strings libname.so
> > > 
> > > Actually, /usr/bin/nm is probably a better bet than any of these.
> > 
> > indeed. i’m still drinking my coffee! 😉
> 
> Brilliant 🙂 Thanks Ara and Greg - they look good.

Interesting that objective c methods are verbosely described in a  
symbol table. From the man pages of nm:

> If the symbol is a Objective C method, the symbol  
> name is  
> ±[Class\_name(category\_name) method:name:], where `+' is for class methods,`-’ is for instance methods, and (category\_name)  
> is present  
> only when the method is in a category.

I don’t remember if objective c method signatures are typed though,  
or if all of the parameters must be object ids? If the later’s the  
case, then you’ve got just about everything you need in the symbol  
table and the header isn’t really needed.
