Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

gcc

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

like image 776
Crazy Chenz Avatar asked Dec 30 '25 15:12

Crazy Chenz


1 Answers

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
like image 115
Glen Avatar answered Jan 01 '26 05:01

Glen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!