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

I have a linker error that says an undefined function reference. In the shared library, where I expect the function to have this function name (I checked through nm -s), now the next thing I want to see is if the parameters of the function are correct. How to find out the type and number of parameters for a function in a shared object file?

EDIT: So the problem was that it was: I tried to create a common C ++ object object by linking a common C object, but in the original C ++ I did not include the header inside the "extern" C "" block, so it doesn’t I could find these characters, thanks to everyone who answered this question. Now this issue has been resolved.

+7
source share
4 answers

You can use nm with the --demangle option:

 nm -s --demangle libWhatever.so 

having tried this on a sample .so gives me a conclusion like

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

T simply means that it is in the object files used to create the .so and does not need linker permission.

+7
source

Try performing C ++ filtering with the changed name. He will untie him, and you can see the arguments.

+2
source

You probably want:

 nm --demangle --defined-only --dynamic x.so 

The above C ++ names display and display only certain characters in the dynamic section, which are denoted by symbols with external communication, with which you can associate.

+2
source

So the problem was this: I tried to create a common C ++ object file by linking a common C object, but in the original C ++ I did not include the header inside the "extern" C "block, so it could not find these characters, thanks to everyone who answered this question, now this question has been resolved.

0
source

All Articles