Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling symbol from .so

I have an .so library, and run nm -gC on it.

I see an output like this:

0011a011 W void my_fun< unsigned char>(unsigned char*, unsigned char, int)

None of the headers that I can include contain this function, but I'd like to call it from my cpp file.

How would I go about doing it?

like image 385
user313724 Avatar asked Apr 24 '26 23:04

user313724


1 Answers

None of the headers that I can include contain this function,

From the nm man page:

W

w

The symbol is a weak symbol that has not been specifically tagged as a weak object symbol.

So it's a weak symbol. If none of the header files declare it, then it may not be defined. You might still try to declare it yourself and call it in case it is (you'll need to link against the library):

void my_fun(unsigned char*, unsigned char, int);

// ...

my_fun(foo, bar, baz);

If this is a C++ function, then you can not use the dlopen() API in a portable manner.


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!