create dll in qt

Creating dll seems an easy task in Qt. In Qt creator,  click File/New File or Project/Projects/Library/C++ Library, then simply choose a name, you will create a dll project. Click “build”, you will see the .dll generated in the debug or release directory. After building the .dll, you can use it in your main application. Your main application can explicitly load the dll at runtime or implicitly link to the dll at compiling time. Either way, the process is straightforward. In the explicit method, you can use QLibrary::load to load the dll,    use QLibrary::resolve to get the address of an exported function, then call that function. If you’re familiar with Windows API, you must know these functions are the packaging of the API LoadLibrary and GetProcAddress. In the implicit method, you need to import the lib of the dll in your main application, then you can use the functions/classes in the dll as if they are defined in your main program. If you dig further, you’ll find more powerful libs as to loading dlls and plugins such as QPluginLoader.

To view this content, you must be a member of Thomas's Patreon at $5 or more
Already a qualifying Patreon member? Refresh to access this content.
Posted in

Leave a Reply