PDA

View Full Version : Dynamic include dll's



Naahmi
15th August 2012, 19:02
Hello,

i want to include dynamicly dll's. Is there a way without link header files in the main project?

tescrin
15th August 2012, 19:43
I'm not sure that your question makes sense. Dlls are dynamic by definition. If you mean you only want to link a dll under certain conditions you could use compile time flags such as:



#define YES_I_WANT_DLLS //comment this line out if you don't want them

#if defined YES_I_WANT_DLLS
#include someLibrary
#endif


and then your program will only check the dlls if that line is uncommented.



If it's trouble including DLLs you need to:
-include the library using your IDE or standard syntax
-add the DLL's location to your "PATH" variable (or move the dlls to a location already in your path variable OR your current directory OR the directory of your .exe)

d_stranz
17th August 2012, 18:07
If you mean you only want to link a dll under certain conditions you could use compile time flags

I don't think this is the OP's problem. I think he wants to load a DLL at run-time, but doesn't have the header files that define the classes and methods inside them so he can't compile that into the source code that uses the DLL.

I don't know how you can do that unless you have some knowledge of what the DLL contains and can tell your program at compile time how to use it, at least to the level of knowing function names and signature.

The QLibrary class has support for dynamic loading of DLLs; you can use the QLibrary::resolve() method at run-time to retrieve a pointer to a method with a known name contained in the library. There are specific requirements for how symbols must be exported from the library when it is compiled.