CReating a DLL whcih can export ‘n’ number of functions for a client application
Helo All,
I would like to develop a .dll with Qt which can be able to export some ‘c’ functions to client application. Can experts guide me on this ?
many thanks,
6 replies
The easiest way to set up a project for a shared library / DLL is to use the Qt Creator New Project… wizard (and select Other Project / C++ Library). That will give you a good starting point with import / export defines etc.
If you want to make it a pure C DLL, the interface obviously has to be pure C, no C++ classes as return values or parameters.
Er.. this (”__declspec(dllexport)” and “__declspec(dllimport)”) is required too.. isn’t it?
MyDllDef.h
- #ifdef INMYLIB
- #define MYLIBDEF __declspec(dllexport)
- #else
- #define MYLIBDEF __declspec(dllimport)
- #endif
MyLib.h
- #include "MyDllDef.h"
- MYLIBDEF void exported_fn();
MyApp.cpp
- #include <MyLib.h>
- void runFn()
- {
- exported_fn();
- }
You might also need to use the extern C.. Look at this Stack Overflow [stackoverflow.com] post on it.
You must log in to post a reply. Not a member yet? Register here!



