Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22006

How can a shared library (.so) call a function that is implemented in its loading program?

$
0
0

I have a shared library that I implemented and want the .so to call a function that's implemented in the main program which loads the library.

Let's say I have main.c (executable) which contains:

void inmain_function(void*);dlopen("libmy.so");

In the my.c (the code for the libmy.so) I want to call inmain_function:

inmain_function(NULL);

How can the shared library call inmain_function regardless the fact inmain_function is defined in the main program.

Note: I want to call a symbol in main.c from my.c not vice versa which is the common usage.


Viewing all articles
Browse latest Browse all 22006

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>