0

I am running in situation where I have two different versions of Qt installed, the compiled with mingw one, and the other with visual studio. Now, When I compile my program with Qt MinGW version and run it, I got a message have scrambled text, saying that one of essential Qt modules not loaded. My question is, how I can set the path to Qt essential modules for my application with C++. I looked at documentation and found addLibraryPath method but it seems like for Qt plugins only.

4

2 回答 2

0

编辑

似乎我误解了这个问题,因为 SIFE 评论说他需要加载 Qt 模块(如 QtGui4.dll),而不是插件。插件的答案留在这里,以防它可能对某人有所帮助。

插件

Qt 加载默认情况下的插件SDK/plugins。问题是,它首先找到了错误的 SDK...

如果我没记错的话,Qt首先在目录中搜索.。因此,您可以复制 *.exe 附近的“插件”目录:在 msvc 编译的 exe 附近复制 msvc 的插件,在 gcc 编译的 exe 附近复制 gcc 的插件。

如果您不想复制plugins目录,可以使用setLibraryPaths(未经测试,但可能有效)

最后但同样重要的是,您还可以使用qt.conf方法。

模块

模块不是动态加载的,因为它们是应用程序依赖项的一部分,所以它们是在 exe 启动时加载的,而不是通过 LoadLibrary 加载的。因此,解决方案很简单:只需将 dll 复制到与包含 *.exe 的文件夹相同的文件夹中即可

于 2012-09-11T08:06:17.637 回答
0

关于编译器,正确的库/包含设置应该由 QMake 完成。QMake 使用 Qmake 所属的同一版本中的库创建您的 makefile/VS-Project。

尝试使用每个 Qt 版本的完整路径显式调用 QMake,例如

c:/myQtMinGwProject>c:/Qt4_mingw/bin/qmake 
c:/myQtVSProject>c:/Qt4_VS2008/bin/qmake -t vcapp

关于运行时,确保相应版本的 dll 在 PATH 中

我希望它有帮助

于 2012-09-14T22:41:16.790 回答