Problem using libraries with MQL5

 
Hi,

I want to create a library, i.e. a set of codes around a certain subject that can be used in different applications. To use a real world example, I want a library that will handle a database that will manage my use of Magic Numbers in order to guarantee my many instances of different EAs will never be loaded with identical magic numbers.

Libraries in C++ can be just a set of functions inside a namespace (e.g. math functions) or they can be organized inside a structure or class. In my database case above, I prefere to put the code inside a class.

In C++, a free functions library is included inside a program just by using "include" to its include file (hpp). In case of a compiled library, an extra include needs to be done (e.g. when working with Qt, one as to use "LIBS += libname" inside the project's .pro file). 

Now how exactly is the equivalent of this in MQL5? I noticed that when creating a library with the wizard, it doesn't create a .mqh file to just put a set of free functions there to be later included as a include file in the main project. Rather, it creates a mq5 file that is compilable. So I assumed what I had do to was pretty much as in C++: I create a .mqh where I declare my class while the mq5 file includes the functions' codes and then I compile. Later I go to my project, include the mqh file in the #include section and now how/where do I add the .ex5? I couldn't find a clue. If I do a #include of the mq5 file, my project works fine. But the idea is not to include that file; formally it could be a third party library which wouldn't provide me with that code, only the mqh and the ex5. So that is wrong. I tried to add the .ex5 library file as an include and it failed and the help file on resources suggest it doesn't work with libraries.

So where do I include the .ex5 file in my project as to use my library without the need to include its mq5 file?
 

See this article which explain how to use libraries with classes.

Promote Your Development Projects Using EX5 Libraries
Promote Your Development Projects Using EX5 Libraries
  • www.mql5.com
Hiding of the implementation details of classes/functions in an .ex5 file will enable you to share your know-how algorithms with other developers, set up common projects and promote them in the Web. And while the MetaQuotes team spares no effort to bring about the possibility of direct inheritance of ex5 library classes, we are going to implement it right now.
 
Alain Verleyen:

See this article which explain how to use libraries with classes.

OMG what a freaking mess!! :| Do you know if MetaQuotes plans to always keep library inclusion that way or if they have plans to make things simpler in the future?

 
Martin Bittencourt:

OMG what a freaking mess!! :| Do you know if MetaQuotes plans to always keep library inclusion that way or if they have plans to make things simpler in the future?

I have no idea about Metaquotes plans. Sorry.