Qt 5.0 program runs in QtCreator but not outside

12,456

Solution 1

This is a dependency problem that your program can not load its dependencies, copy dependency files (DLL files) to application directory is a temporary way, this is very risky way that your application may faced with problems in target machine, if target machine does not have correct version of Microsoft Runtime Library installed on them, your application can not run correctly, you can find which dependenices (DLL files) your application needs them with Dependency Walker.

There are two ways to solve this:

First one is to use Microsoft Visual C++ 2010 Runtime components in your installshield (or another versions depends on which version of Runtime library you compiled with it), that user could install it silently, or install with its executable binary without use installshield, and later copy DLL files to application directory and distribute it.

Second is use static compilation method to avoid such problems like that, but for static compile of your application you need a Commercial License if you want to distribute it on target machines.

For Deploy Your Application on target machines:

1) Put Microsoft Visual C++ 2010 Runtime Library in your application folder, so user will install it on their machine.

2) Copy application required dependencies (DLL files) from Qt's bin folder in your application folder (bin folder path:C:\Qt\Qt5.0.2\5.0.2\msvc2010\bin).

3) Copy imageformats folder from your Qt's plugins folder in your application folder (if you use any image resource file in your application).

4) Copy platforms folder from your Qt's plugins folder in your application folder.

Qt's plugins folder path: C:\Qt\Qt5.0.2\5.0.2\msvc2010\plugins\

Solution 2

The Qt-project site is full of such topics. Tracking dependencies will only inform of compile time dependencies. There are also DLLs that are loaded dynamically you wont' get any error, warning or whatsoever. If you use a stock build the DLLs (excluding Qt5*.dll) you'd need are:

  • D3DCompiler_46.dll (sometimes D3DCompiler_43.dll)
  • libEGL.dll
  • libGLESv2.dll
  • icudt49.dll
  • icuin49.dll
  • icuuc49.dll
  • platforms\qwindows.dll (or whatever your os is)

Plus compiler runtime dlls depending on what build you are using.

You can cut on dependencies significantly if you build with desktop OpenGL support instead of ANGLE and without the webkit. Then you only need the platform plugin and the Qt modules you are using.

Share:
12,456
Darkiwi
Author by

Darkiwi

Updated on June 17, 2022

Comments

  • Darkiwi
    Darkiwi almost 2 years

    Here is the context:

    • I have developed a program with Qt under Windows 7 x64.
    • I have upgraded to Qt 5.0.1, QtCreator 2.6.1, Compiler VS2010.

    Now the status:

    • My program runs fine in QtCreator but, when I tried it outside, I received several errors.
    • I checked this topic which gave me some answers: qtcreator - exe does work fine inside qtcreator but doesn't outside
    • I thus added Qt dlls and it helped, no more Missing Libraries messages.
    • Still, it would not run outside QtCreator (no more error message, I just doesn't run) so I added the platforms directory with both qminimal and qwindows dlls, it didn't help.
    • I also downloaded and added libEGL.dll as sugested, with no result.

    I'm stuck and could really a little help.