QT - 在pro中指定DLL路径。文件 [英] QT - Specify DLL path in pro. file

查看:1126
本文介绍了QT - 在pro中指定DLL路径。文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如问题标题所说,我特别想知道如何在实际的项目文件中包括一个.dll文件的路径。我知道这是更好的做法,包括dll文件与项目文件,但我仍然只是想知道是否可以做到吗?

So as the question title says, i'm specifically wondering how to include the path to a .dll file in the actually project file. I know it's the better practice to include the dll file with the project file, but i'd still just like to know if it's possible to be done?

目前我的.pro文件包含以下内容:

Currently my .pro file consists of the following;

QT       += core gui

TARGET = Test
TEMPLATE = app

win32 {
    INCLUDEPATH += "D:/Projects/Build Output/include/"

    CONFIG(debug, debug|release) {
        LIBS += "D:/Projects/Build Output/libs/debug/myLib.lib"
        LIBS += "D:/Projects/Build Output/bin/x86 debug/myLib.dll"
    } 
    else {
        LIBS += "D:/Projects/Build Output/libs/release/myLib.lib"
        LIBS += "D:/Projects/Build Output/bin/x86 release/myLib.dll"
    }
}

SOURCES += main.cpp\
    mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

会很酷,只是知道它可以做,感谢提前为你的帮助:)。

Would be cool, just to know that it can be done, thanks in advance for your help :).

推荐答案

如果你想要生成的exe可以在运行它自动找到它的依赖dll文件,对于隐式dll链接(即链接到.lib文件,如在你的例子)。 Windows具有固定搜索顺序找到必要的dll文件。这些序列都不能放入QT pro文件。所以下面的语句没有效果只让QT知道在该路径中搜索dll的.lib / .a文件:

If you mean you want the generated exe can find its dependant dll files automatically upon you run it, then it cannot be done for implicit dll linking (i.e. linking with .lib files, as in your example). Windows has a fixed search sequence to locate the necessary dll files. None of those sequence can be put into a QT pro file. So the following statement has no effect only makes QT know to search the dll's .lib/.a file in that path:

 LIBS += "D:/Projects/Build Output/bin/x86 debug/myLib.dll"


b $ b

最接近的方法可能是将dll路径定义为pro文件中的宏。然后使用LoadLibrary 从这些文件中显式加载dlls 路径在c / c ++源文件中。当然,如果你可以通过显式链接而不是隐式链接来解决,

The closest approach might be defining the dll paths as the macros in the pro file. Then use LoadLibrary to explicitly load dlls from those paths in your c/c++ source file. Of course only if you can settle with explicit linking instead of implicit linking,

这篇关于QT - 在pro中指定DLL路径。文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆