static - C++ shared library export function -


i want write plugin application. application brings plugin header- , c-file written exported functions fill. make development easier want create c++ "api". created base classes virtual functions (required functions abstract) , call functions plugin c-file. "api" should in static library file.

the real plugin (a shared library) should include static library, derive , implement needed classes.

now problem: how export function included static lib in shared lib (so application calls functions static lib)? possible?

usually if want have plugin mechanism c++ common way of doing it:

// plugin file extern "c" baseclass* create() {     return new derivedclass; }  extern "c" void destroy(baseclass* base) {     delete base; } 

then in code uses plugin you're dealing baseclass without caring derivedclass pointing to. methods need export plugin should put in baseclass , make them virtual.

note1: make sure call destroy function instead of using delete may overloaded in application not in plugin library or vice versa.

note2: don't forget make destructor of base class virtual.

note3: should careful when using c++ api dynamic loading libraries. problem compiler mangles c++ class , function names. if happen compile application , plugin library different compilers or different versions of same compiler linker may not able resolve function name correctly find in plugin's library.

note4: same problem above can happen if changes in application making compiler change name mangling existing functions. please here more info on this.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -