Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Usage of Created Dll's with Header Files



  • Hi everyone,

    I created a library which only creates one dll file. However, library includes more than 20 thousands of code, and each class is in different h/cpp files.

    For the developer to use my library, they have to include all header files into the project. However they only wanted to include one header.

    For example I have class A, Class B and class C.
    They only want to have the header of class A but not the others.

    Is there any way to do this? Currently they are putting all headers in to the directory of their project.



  • @DzCode
    For one thing it depends on how the .h files cross reference to each other. If, say, classA.h goes #include "classB.h" you would need both files present to include the first one.

    If you are the author of the DLL you should think about what you actually need to expose to users of your library/DLL. Do you need to expose everything? Do your classes include instances of other classes (bad for including) or do they include pointers to instances to other classes (better for including)? Etc.



  • @JonB It includes both pointer objects and non-pointer objects of other classes.

    Does forward declaration solve this problem?


  • Lifetime Qt Champion

    @DzCode said in Usage of Created Dll's with Header Files:

    Does forward declaration solve this problem?

    Try it out?



  • @JonB By the way, I have only exposing the one class to the outside world. Only one class has Q_DECL_EXPORT keyword



  • Forward declaration is the solution


Log in to reply