Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the complete function definition inside C++ shared object file

I have a linker error where it says undefined reference to a function. The shared library where I expect the function to be has that function name ( I checked through nm -s ) so now the next thing I want to see is if the function parameters are correct. How do I see the type and number of parameters for a function in a shared object file ?

EDIT: So the problem it came to be was: I was trying to create a C++ shared object file by linking a shared C object, but in the C++ source I did not include the header inside "extern "C" " block, so it was not able to find those symbols, Thanks to all who replied to this question. This question is resolved now.

like image 721
avd Avatar asked May 08 '12 14:05

avd


People also ask

How do I view the contents of a .so file?

However, you might be able to read the SO file as a text file by opening it in a text editor like Leafpad, gedit, KWrite, or Geany if you're on Linux, or Notepad++ on Windows.

What is a shared object in C?

A shared object is an indivisible unit that is generated from one or more relocatable objects. Shared objects can be bound with dynamic executables to form a runable process. As their name implies, shared objects can be shared by more than one application.

Where are shared objects stored?

These shared objects are named with the extension . fso and are stored on the server in a subdirectory of the application that created the shared object. Adobe Media Server creates these directories automatically; you don't have to create a directory for each instance name.

What is shared object file in Linux?

so (short for "shared object"). Shared libraries are the most common way to manage dependencies on Linux systems. These shared resources are loaded into memory before the application starts, and when several processes require the same library, it will be loaded only once on the system.


1 Answers

You can use nm with the --demangle option:

nm -s --demangle libWhatever.so

trying that out on a sample .so gives me output such as

00005820 T detail::print_(std::ostream&, cv::Mat const&, std::string const&)

T just means that it is in the object files used to make the .so and does not need to be resolved by the linker.

like image 170
juanchopanza Avatar answered Nov 09 '22 08:11

juanchopanza