应用程序exe依赖的Dll放入其他目录

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012020854/article/details/79481605
//exe的pro文件中要加:
DESTDIR = $${LoadLibPath} //exe输出路径
LIBS += -L$${LoadLibPath} -L$${LoadLibPath}/RoDlls //lib或.a或.so依赖路径
#ifdef Q_OS_WIN
#include <Windows.h>
#endif
int main(int argc, char **argv) {
    //指定exe加载dll路径
#ifdef Q_OS_WIN
    QString s = "RoDlls";
    LPCWSTR path = s.toStdWString().c_str();
    SetDllDirectory(path); //window下设置依赖dll路径
#endif
}

这样使用Qt Creator编译时可以运行
单独发布exe不行。。。
需要升级update.exe启动main.exe才有效果, 不然找不到DLL加载路径

猜你喜欢

转载自blog.csdn.net/u012020854/article/details/79481605