POCO_BEGIN_MANIFEST problem

Please post support and help requests here.
maghasyan
Posts: 4
Joined: 18 Oct 2009, 21:39

POCO_BEGIN_MANIFEST problem

Postby maghasyan » 19 Oct 2009, 14:10

Hello,

I have problem creating shared object library.
When I put the block

Code: Select all

POCO_BEGIN_MANIFEST ... POCO_END_MANIFEST
in the .cpp where the class methods are declared everything is ok. But the problem is that I have 2 different libraries to create and the class exported in one of them is derived from the class exported in another. And when I try to link these two .o files it gives an error that multiple manifest definitions exist.
So I want to move the block

Code: Select all

POCO_BEGIN_MANIFEST ... POCO_END_MANIFEST
to a separate .cpp file. But in this case I get "multiple definition of ..." errors (because the .h file containing class definition is included in both .cpp files).
Please tell me how can I make the library with manifest declaration in separate .cpp file. Thanks.

alex
Posts: 1294
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: POCO_BEGIN_MANIFEST problem

Postby alex » 19 Oct 2009, 14:49

Try POCO_BEGIN_NAMED_MANIFEST

maghasyan
Posts: 4
Joined: 18 Oct 2009, 21:39

Re: POCO_BEGIN_MANIFEST problem

Postby maghasyan » 19 Oct 2009, 15:08

alex wrote:Try POCO_BEGIN_NAMED_MANIFEST


Thanks. But now it says "No manifest in ..." :(

guenter
Posts: 1194
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: POCO_BEGIN_MANIFEST problem

Postby guenter » 19 Oct 2009, 15:16

Since the manifest is nothing more than a function with a specific name in the plugin shared library, you obviously cannot link two plugin shared libs together. You should put the common code of the two plugins in a separate library, and then link to that library from both plugins. For the first plugin, create a new shared library that only contains the manifest (and links the common library). For the second plugin, create a shared library containing the subclass and the manifest.

alex
Posts: 1294
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: POCO_BEGIN_MANIFEST problem

Postby alex » 19 Oct 2009, 15:44

Guenter is right. I did not read the post carefully enough.

maghasyan
Posts: 4
Joined: 18 Oct 2009, 21:39

Re: POCO_BEGIN_MANIFEST problem

Postby maghasyan » 20 Oct 2009, 12:04

Thank you all.
It worked without making separate library. The problem was in my Makefile.

But now I have another problem. I have exported my class as singleton. I want to store a pointer/reference to that singleton object in the member variable to use it later without dealing with manifests/metas each time.

I tried this way. On startup I get reference to my singleton object and store it's address in the pointer member variable:

Code: Select all

   Poco::ClassLoader<IRank> cl;
   try
   {
      cl.loadLibrary(path);
      poco_assert(cl.isLibraryLoaded(path));

      const Poco::ClassLoader<IRank>::Manif* pManifest = cl.findManifest(path);
      poco_check_ptr(pManifest);

      Poco::ClassLoader<IRank>::Manif::Iterator it = pManifest->begin();
      Poco::ClassLoader<IRank>::Manif::Iterator itEnd = pManifest->end();
      if (pManifest->begin() != pManifest->end())
      {
         const Poco::AbstractMetaObject<IRank>* pMeta = *pManifest->begin();
         poco_check_ptr(pMeta);
         m_pRank = &pMeta->instance();
      }
   }
   catch (Poco::Exception ex)
   {
   }


But when I try to invoke a method on m_pRank later the application crashes with segmentation fault. So I think the object is not in the memory anymore.

Any ideas?

alex
Posts: 1294
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: POCO_BEGIN_MANIFEST problem

Postby alex » 20 Oct 2009, 12:37

maghasyan wrote:Any ideas?

Perhaps cl is out of scope at the place where you invoke a method on m_pRank?

maghasyan
Posts: 4
Joined: 18 Oct 2009, 21:39

Re: POCO_BEGIN_MANIFEST problem

Postby maghasyan » 20 Oct 2009, 12:42

alex wrote:
maghasyan wrote:Any ideas?

Perhaps cl is out of scope at the place where you invoke a method on m_pRank?


Yes, cl is out of scope.
But I have solved the problem by changing singleton export to normal export. Now, on startup I am creating an object and storing it in the member variable (the pointer) and deleting it on application shutdown. Everything is ok.
Thanks.


Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests

cron