Using Reflex as standalone solution for C++ reflection

I am trying to use Reflex by itself (without ROOT/CINT) in order introduce reflection information into my C++ programs. Unfortunately I haven’t been able to get it working using the documentation available on the Reflex website. I have a feeling like I’m missing an important step. I’ve generated the reflection data as it is described and it seems to work without problems. As a result, a *_rflx.cpp file is created containing (what I believe to be) the correct reflection data. However, my question is: What am I supposed to do next? The website jumps right to the usage with several examples. I’ve tried adding the generated file to my project and using reflection data as it is described in the examples. However, the following always return garbage resulting in a crash:

ROOT::Reflex::Type::ByTypeInfo(typeid(core::Object)); //or ROOT::Reflex::Type::ByName("core::Object");
Looking at some of the Reflex tests, it appears that the reflection data is dynamically loaded from external libraries. Do I need to compile a library first? If yes, how?


yes, it’s probably best to build the reflection data into a shared library. For how to do that you’ll have to check your platform’s users guide or the web - it’s very different for different unixes, windows,… The tests should show you (when run with make VERBOSE=1) how its’ done on your platform.

You then simply load the shared library (again a bit platform dependent, see tests) and the code you showed should work.

Cheers, Axel.

Thank you for your reply. Good to know my hunch that I would need a library was indeed correct. Unfortunately, I’m far from being an expert when it comes to shared libraries. To make things even worse, I rarely use command line tools to build my programs. I’m used to developing on Windows with Visual Studio (2008). I tried to build the library using this setup (simply by creating a new project in VS2008 using the dynamic library configuration and adding the *_rflx.cpp and all necessary sources). The resulting *.dll is loaded without errors, but it doesn’t do any difference in regard to the problems I had before. Do I need to put something in my DllMain or anything like that? Or do I have to build the library using some special settings?