Greeting

I created plugin with Qt (5.6.2) and trying to load it but it returns null all the time. I checked several question and also tried the solutions but it didn't work for me.

Can you take a look of the following code and see whats wrong?

DeviceManager.hpp

Qt Code:
  1. #ifndef DEVICE_MANAGER_HPP
  2. #define DEVICE_MANAGER_HPP
  3.  
  4. #include <QtCore>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. class DeviceManager
  10. {
  11.  
  12. public:
  13. virtual ~DeviceManager() {}
  14.  
  15. virtual bool initialize() = 0;
  16. virtual string getBrandName() = 0;
  17.  
  18. };
  19.  
  20. QT_BEGIN_NAMESPACE
  21. Q_DECLARE_INTERFACE(DeviceManager, "com.some.address/1.0")
  22. QT_END_NAMESPACE
  23.  
  24. #endif //DEVICE_MANAGER_HPP
To copy to clipboard, switch view to plain text mode 

DeviceManagerImpl.hpp

Qt Code:
  1. #ifndef DEVICE_MANAGER_IMPL_HPP
  2. #define DEVICE_MANAGER_IMPL_HPP
  3.  
  4. #include "DeviceManager.hpp"
  5.  
  6. #include <string>
  7. using namespace std;
  8.  
  9. class DeviceManagerImpl : public QObject, public DeviceManager
  10. {
  11. Q_OBJECT
  12. Q_PLUGIN_METADATA(IID "com.some.address/1.0")
  13. Q_INTERFACES(DeviceManager)
  14.  
  15. public:
  16. DeviceManagerImpl();
  17.  
  18. //Override Method
  19. bool initialize(); //Have implementation in cpp file
  20. string getBrandName(); //Have implementation in cpp file
  21.  
  22. private:
  23. ...
  24.  
  25. };
  26.  
  27. #endif //DEVICE_MANAGER_IMPL_HPP
To copy to clipboard, switch view to plain text mode 

Pro File

Qt Code:
  1. QT += core gui sql
  2.  
  3. TARGET = Device-Manager
  4. #TARGET = $$qtLibraryTarget(Device-Manager)
  5. TEMPLATE = lib
  6. CONFIG += plugin
  7.  
  8.  
  9. SOURCES += \
  10. ...
  11.  
  12. HEADERS += \
  13. ...
  14.  
  15. DISTFILES += Device-Manager.json
  16.  
  17. unix {
  18. target.path = /usr/lib
  19. INSTALLS += target
  20. }
To copy to clipboard, switch view to plain text mode 

And this is how i try to load the plugin in my main process.

Qt Code:
  1. QPluginLoader * pluginLoader = new QPluginLoader(pluginPath.c_str());
  2. QObject * plugin = pluginLoader->instance();
  3.  
  4. if (plugin)
  5. {
  6. deviceManager = qobject_cast<DeviceMAnager *>(plugin);
  7. return true;
  8. }
  9. else
  10. {
  11. delete pluginLoader;
  12. return false;
  13. }
To copy to clipboard, switch view to plain text mode 

Im using QT 5.6.2 and QT Creator and MinGW 32bit.

Thanks in advance.