C/C++ plug-in programming
I wonder how to read the content of a shared object inside my c/c++ source code. Let me explain more.
Imagine i have a main.c file and it can get 2 int numbers and add them, then i compile this file using gcc and then i have an executable file.
after a while i notice that i like to add subtraction ability(function) to my simple program. there are 4 major way to do it:
1) adding the code inside to source file (main.c) and recompiling it.
2) creating another source file and implementing the new function into it, then compiling it as an static or shared object and the recompiling the main.c against this object file
3) using and embedding an scripting language, say perl or lua, to add the new functionality as scripts files into our executable program. this approach is useful in some situation, but here you have to force the end user to download another program (perl, lua, ...) to be able to run your app correctly, or it would lack a lot of functionalities, though you won't need to recompile your app.
4) embedding a peace of code, i mean new function into main.c to read and deal with the content of a directory, say "./plugin" at runtime and checking if there is any shared library within the directory, if any, reading their contents and adding the extra functionality to the main program on the fly.
so, my question is that how can we implement the fourth approach? in other words, how can we read the content of shared objects on the fly?
Last edited by opengl_cpp; 17 Minutes Ago at 02:07 AM..