• <bdo id='X7hnJ'></bdo><ul id='X7hnJ'></ul>

    <tfoot id='X7hnJ'></tfoot>
  1. <i id='X7hnJ'><tr id='X7hnJ'><dt id='X7hnJ'><q id='X7hnJ'><span id='X7hnJ'><b id='X7hnJ'><form id='X7hnJ'><ins id='X7hnJ'></ins><ul id='X7hnJ'></ul><sub id='X7hnJ'></sub></form><legend id='X7hnJ'></legend><bdo id='X7hnJ'><pre id='X7hnJ'><center id='X7hnJ'></center></pre></bdo></b><th id='X7hnJ'></th></span></q></dt></tr></i><div id='X7hnJ'><tfoot id='X7hnJ'></tfoot><dl id='X7hnJ'><fieldset id='X7hnJ'></fieldset></dl></div>

      <small id='X7hnJ'></small><noframes id='X7hnJ'>

    1. <legend id='X7hnJ'><style id='X7hnJ'><dir id='X7hnJ'><q id='X7hnJ'></q></dir></style></legend>

      将 .dll 导入 Qt

      Importing .dll into Qt(将 .dll 导入 Qt)

        <tbody id='8MYb6'></tbody>
    2. <legend id='8MYb6'><style id='8MYb6'><dir id='8MYb6'><q id='8MYb6'></q></dir></style></legend>

      <small id='8MYb6'></small><noframes id='8MYb6'>

      1. <tfoot id='8MYb6'></tfoot>

          • <i id='8MYb6'><tr id='8MYb6'><dt id='8MYb6'><q id='8MYb6'><span id='8MYb6'><b id='8MYb6'><form id='8MYb6'><ins id='8MYb6'></ins><ul id='8MYb6'></ul><sub id='8MYb6'></sub></form><legend id='8MYb6'></legend><bdo id='8MYb6'><pre id='8MYb6'><center id='8MYb6'></center></pre></bdo></b><th id='8MYb6'></th></span></q></dt></tr></i><div id='8MYb6'><tfoot id='8MYb6'></tfoot><dl id='8MYb6'><fieldset id='8MYb6'></fieldset></dl></div>

            • <bdo id='8MYb6'></bdo><ul id='8MYb6'></ul>
                本文介绍了将 .dll 导入 Qt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想将 .dll 依赖项引入我的 Qt 项目.

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

                所以我将它添加到我的 .pro 文件中:

                So I added this to my .pro file:

                win32 {
                LIBS += C:libdependency.lib
                LIBS += C:libdependency.dll
                }
                

                然后(我不知道这是否是正确的语法)

                And then (I don't know if this is the right syntax or not)

                #include <windows.h>
                Q_DECL_IMPORT int WINAPI DoSomething();
                

                顺便说一句,.dll 看起来像这样:

                btw the .dll looks something like this:

                #include <windows.h>
                BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, 
                                                        LPVOID lpReserved)
                {
                    return TRUE;
                }
                
                extern "C"
                {
                int WINAPI DoSomething() { return -1; }
                };
                

                出现错误:未解析的符号?

                Getting error: unresolved symbol?

                注意:在 .NET 的 ez pz 程序集架构之外,我对 .dll 没有经验,绝对是 n00b.

                Note: I'm not experienced with .dll's outside of .NET's ez pz assembly architechture, definitely a n00b.

                推荐答案

                您的LIBS +="语法错误.试试这个:

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

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

                我也不确定在 .pro 文件中使用带驱动器号的绝对路径是否是个好主意 - 我通常将依赖项保留在项目树中的某处并使用相对路径.

                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.

                我想你的 dll 有问题,即符号没有正确导出.我总是使用 QtCreator 提供的模板:

                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. 在 dll 项目中有 mydll_global.h 头文件,代码如下:

                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
                

              • Dll 项目的 pro 文件中有 DEFINES += MYDLL_LIB.

              • Dll project has DEFINES += MYDLL_LIB inside it's pro file.

                导出的类(或仅选定的方法)和自由函数在头文件中用 MYDLL_EXPORT 标记,即

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

                class MYDLL_EXPORT MyClass {
                
                // ...
                
                };
                

              • 这篇关于将 .dll 导入 Qt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                Delay Loading DLLs(延迟加载 DLL)
                Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                Loading a dll from a dll?(从 dll 加载 dll?)
                <legend id='xXElM'><style id='xXElM'><dir id='xXElM'><q id='xXElM'></q></dir></style></legend>

                      <bdo id='xXElM'></bdo><ul id='xXElM'></ul>

                          <tbody id='xXElM'></tbody>

                        <i id='xXElM'><tr id='xXElM'><dt id='xXElM'><q id='xXElM'><span id='xXElM'><b id='xXElM'><form id='xXElM'><ins id='xXElM'></ins><ul id='xXElM'></ul><sub id='xXElM'></sub></form><legend id='xXElM'></legend><bdo id='xXElM'><pre id='xXElM'><center id='xXElM'></center></pre></bdo></b><th id='xXElM'></th></span></q></dt></tr></i><div id='xXElM'><tfoot id='xXElM'></tfoot><dl id='xXElM'><fieldset id='xXElM'></fieldset></dl></div>
                      1. <tfoot id='xXElM'></tfoot>
                        1. <small id='xXElM'></small><noframes id='xXElM'>