tags:

views:

49

answers:

2

What is the best way to find what library a function may belong to?

When building source code, I sometimes get "undefined reference to" errors. When they are function calls, I'd like to know what libraries need to be linked in more easily than my usual guessing game. Any ideas?

-Chenz

+2  A: 

As far as I know you're pretty much out of luck as far as an automated solution goes.

You could try dumping all the symbols from all you usual libraries to file and grepping through the results to find the one you're looking for. You'd only have to do the dumping infrequently

I think the unix tool "nm" is what you're looking for. I don't know about windows, sorry

Something like the following should do it on Linux:

find . -name "*.so" -print0 | xargs -0 nm -A | egrep ' [TWDB] ' > symbols.out
Glen
A: 

you could try looking the function up with man or on msdn.microsoft.com depending upon OS. Both manuals indicate the library in which the function exists. Failing that, if you're using a custom library, you could use the docs for that custom lib. And failing that, Glen's recommendation of using nm to identify all symbols in all libraries can do it.

atk