开发者

Testing a simple qt console program on non-qt-installed pc

The code is very simple:

#include <QApplication>
#include <QDebug>

int main(int argc,char* argv[])
{
    QApplication a(argc,argv);
    qDebug()<<"Hello world!";
    return a.exec();
}

And the .pro file's content is:

CONFIG+=qt debug console
SOURCES+=a.cpp
TARGET=trytoshow

I used the dumpbin utility to find out on which .dll the console program depends: C:\Program Files\Microsoft Visual Studio 9.0\VC>dumpbin -dependents "G:\Public\H ello world\trytoshow.exe" Microsoft (R) COFF/PE Dumper Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved.

Dump of file G:\Public\Hello world\trytoshow.exe

File Type: EXECUTABLE IMAGE

Image has the following dependencies:

QtGuid4.dll
QtCored4.dll
MSVCR90D.dll
KERNEL32.dll

Summary

    1000 .data
    1000 .idata
    2000 .rdata
    1000 .rsrc
    4000 .text

So I put the trytoshow.exe, qtguid4.dll, qtcored4.dll and 开发者_StackOverflow社区a folder named "Debug_NonRedist", which is from C:\Program Files\Microsoft Visual Studio 9.0\VC\redist, into a directory. Then I released it to a non-qt-installed pc. It does not run.

Did I do anything wrong? Thank you.


As winterTTr already pointed out in the comment to your post, it would be important to know what "It does not run" really means.

There could be more dependencies used by the (Qt) Dll's, so I would suggest to have a look at the ouput of Dependency Walker when you start the program to find out what might be missing (you can use the "Profiling" functionality of the program to do that). You can find it here: http://www.dependencywalker.com/


If you want to use a debug version of your program, you should also use the debug version of the relevant dlls. If i remember correctly, there is debug version of Qt dll, such as QtCored4.dll, QtGui4d.dll, and etc.

On the other hand,
if you find "This application has failed to start because the application configuration is incorrect", normally, this is because the debug version runtime library on the target machine may not be same as where you compile it. So, you can use static runtime library link for your application, that should solve this problem.

For vs2010, Under Configuration Properties, C/C++, Code Generation, Runtime Library -> MultiThreaded (/MTd), which is the /MTd compile parameter for cl.exe. You can also try to find how to set it in qt application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜