#1 2014-05-30 02:18:44

tchen87
Member
Registered: 2014-05-30
Posts: 1

Help with Example projects

Hello,

Love the work - have switched over to C++ recently and am happy to see this sort of OSGi port available. I am having some difficulty in running the example projects correctly (Building with CMake 2.8.12.2 and VS2012 on Windows 7). Though the general functionality seems to be working fine, there are a couple kinks when I try to follow the steps in the tutorial.

The eventlistener seems to have a problem performing the ref_any_cast, throwing the BadAnyCastException.
In the tutorial, it seems that the loading of the dictionaryclient module causes the dictionaryservice module to automatically load as well. However, when I try it, the dictionaryservice does not automatically load even though I've built the project with the US_ENABLE_AUTOLOADING_SUPPORT configuration activated in CMake.

Do you have any suggestions for troubleshooting the above behavior?

Thanks for your time,

Offline

#2 2014-06-02 01:31:31

sascha
Administrator
Registered: 2012-05-04
Posts: 46

Re: Help with Example projects

Hi,

thanks for trying CppMicroServices! The eventlistener module does indeed have a bug related to some refactoring which happened before the 2.0 release. I opened GitHub Issue 20 and fixed it in branch 20-event-listener-example-module (based on the 2.1.0 release).

The automatic loading of the dictionaryservice module actually depends on the linker and optimization flags of your particular toolchain. It is not related to the US_ENABLE_AUTOLOADING_SUPPORT configuration. The dictionaryclient module uses the service interface from the dictionaryservice module and hence naively has a link-time dependency to it. However, some linkers (also depending on certain flags and enabled optimization strategies) are able to optimize this link-time dependency away. Hence the dictionaryservice module will not be loaded by the dynamic linker at runtime. The note in Example 6 also tries to explain this a bit.

Hote this helps,

Sascha

Offline

#3 2015-01-15 15:25:22

Tom
Member
Registered: 2015-01-15
Posts: 1

Re: Help with Example projects

sascha wrote:

The dictionaryclient module uses the service interface from the dictionaryservice module and hence naively has a link-time dependency to it.
Sascha

Hi, I do not think using an interface means link-time dependency. If you do not create an inctance of the interface directly in the consumer module, there will be no link-time dependency, just as in this dictionaryclient example, you can remove the input of 'dictionaryservice' lib from dictionaryclient module. Actually, this is just what I want, loosely coupled modules?

PS: I think CppMicroServices is a great project and I really appreciate your efforts.

Thanks.
Tom

Offline

#4 2015-01-19 02:33:35

sascha
Administrator
Registered: 2012-05-04
Posts: 46

Re: Help with Example projects

Hi Tom,

thank you for your interest in CppMicroServices!

You are right that in theory, using interfaces does not mean link-time dependency - where interface is typically defined to represent a class with only pure virtual functions.

In the discussion above, I tried to explain why the dictionary example might contain link-time dependencies - it depends on the platform and compiler optimization level because the interface contains an out-of-line virtual destructor (this is needed for correct dynamic_cast behavior with older gcc compilers).

Best,
Sascha

Offline

Board footer

Powered by FluxBB