You are not logged in.
Pages: 1
Id like to make my program use plugins for certain functions, ideally it would load a .so file and then check if a certain function exists in it,
if yes it uses the function in the plugin otherwise it uses its own function.
Also id need to be able to access all (or atleast some specific ones) functions/global variables of the main program from within the function in the .so file.
Is this doable somehow? if yes how? ^^
Links to some guides etc would be neat as i havent found much usefull stuff about it yet.
Offline
How portable do you want to be? Check out `man dlopen`.
Offline
It only needs to run on a standart linux system , so portability isnt really an issue.
Gonna poke around with dlopen and see how it works.
Offline
Seems to be exactly what i needed, thanks ^^
Just one more thing, is there any other way to access functions/global vars from the main program other than passing pointers for them to the library files?
Offline
I'd strongly suggest passing anything the library needs as a param somehow. The library really, _really_ should not depend on the main.
Offline
Since you are going to write it in C++ will you write it with classes? If you are going to do that, I have some code that uses dlopen and is written to handle classes. The code is used in a personal project which I am coding on, it will eventually be published. If you (or anyone else) is interested in the code for the module loading, I could upload it somewhere (I could have done that right now but it's on another computer that I own).
Offline
Sure you can upload it and link it here for anyone else that might be intereseted ^^
I will probably have both classes and normal c functions, im still kinda n00b to c++ so my apps are quite a mess =P
Offline
Sure you can upload it and link it here for anyone else that might be intereseted ^^
Sure! The code lacks documentation at this point but I hope that I can answer any questions. Anyway, there is an example included with the code.
twpamodule.tar.gz
Offline
Interesting howto to read: http://www.faqs.org/docs/Linux-mini/C++-dlopen.html
My code is inspired of the examples in the howto but I have tried to make mine a bit more reusable.
Offline
Ty for the link ^^
Offline
Pages: 1