Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Qt 5.0 program runs in QtCreator but not outside

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.

like image 546
Darkiwi Avatar asked Feb 17 '23 02:02


1 Answers

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\

like image 116
Reza Ebrahimi Avatar answered Feb 28 '23 07:02

Reza Ebrahimi