Importing .dll into Qt

后端 未结 3 1054
情话喂你
情话喂你 2020-12-15 02:26

I want to bring a .dll dependency into my Qt project.

So I added this to my .pro file:

win32 {
LIBS += C:\\lib\\dependency.lib
LIBS += C:\\lib\\depe         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 02:38

    Your "LIBS +=" syntax is wrong. Try this:

    win32 {
        LIBS += -LC:/lib/ -ldependency
    }
    

    I'm also not sure if having absolute paths with drive letter in your .pro file is a good idea - I usually keep the dependencies somewhere in the project tree and use relative path.

    EDIT:

    I suppose that something is wrong in your dll, i.e. the symbols are not exported correctly. I always use template provided by QtCreator:

    1. Inside dll project there is mydll_global.h header with code like that:

      #ifdef MYDLL_LIB
          #define MYDLL_EXPORT Q_DECL_EXPORT
      #else
          #define MYDLL_EXPORT Q_DECL_IMPORT
      #endif
      
    2. Dll project has DEFINES += MYDLL_LIB inside it's pro file.

    3. Exported class (or only selected methods) and free functions are marked with MYDLL_EXPORT inside header files, i.e.

      class MYDLL_EXPORT MyClass {
      
      // ...
      
      };
      

提交回复
热议问题