Re: [Cppcms-users] Plugins and templates
Brought to you by:
artyom-beilis
From: Artyom <art...@ya...> - 2010-08-19 11:44:31
|
> > The problem is, this doesn't work either, still getting std::bad_cast > exceptions. It works only if you cast the shared_ptr to > content::hello_plugin by dynamic_pointer_cast before passing it to > render(). And that's the point - the dispatcher does not know which > class to cast to. > Before we continue lets see following: Is following happens (I think now I undestand what happens)? You load plugin foo - say libfoo.so You load skin libfoo_view.so that uses class that created in libfoo.so ? You compile a cppcms application bar with -rdynamic and it fails. Am I right? If so, what happens is following. libfoo is loaded and libfoo_view.so is loaded but each one of them do not see symbols one of other. If so you need to do one of following: 1. Make sure libfoo.so loads first before libfoo_view.so (i.e. before creating service instance) 2. When you load libfoo.so you need to dlopen it with RTLD_GLOBAL flag so libfoo_view.so will see it symbols. 3. Then load libfoo_view.so. So this probably should be You may also make sure that libfoo_view.so loads with RTLD_GLOBAL but for this you need to change a little the code in CppCMS: src/views_pool.cpp And change the line: handler_ = dlopen(file_name.c_str(),RTLD_LAZY); to handler_ = dlopen(file_name.c_str(),RTLD_LAZY | RTLD_GLOBAL); And laso dlopen your plugins with this flag. Then all symbols will be visible to pluging and views and casing would work. Simplest way to check if this helps: before you alter the code just write in int main(int argv,char **argc) { void *h = dlopen("/path/to/plugin.so",RTLD_LAZY | RTLD_GLOBAL); } If this helps then these changes I'm talking would help and I'll update CppCMS to load libraries with this flag. Artyom - |