omninonsense
omninonsense

Reputation: 6882

Applications works while debugging, but doesn't work when "released"

So, I just made a standard, QtQuick 2 application, it has the default Recangle, Text and MouseArea. So, I just tried to compile the application in release mode, to see what files it would generate, and then I tried opening the application and this happened:

When I resize it, I cans see white space:

However it all works fine in debugging:

enter image description here

I am using Qt 5.0.1 and QtQuick2

Update

So, after running it through Dependency Walker it appears like there are three files missing: qt5quick.dll, qt5gui.dll, and qt5core.dll. Do I have to manually add them from somewhere?

The current directory structure is:

`test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release/release
|+qml
 |+test
  |-main.qml
|-main.obj
|-moc_qtquick2applicationviewer.cpp
|-moc_qtquick2applicationviewer.obj
|-qtquick2applicationviewer.obj
|-test.exe
|-test.exe.embed.manifest

Note: I pasted the qml directory as suggested in Nemanja Boric's answer from the parent directory, but that didn't solve the problem! :(

Also, I was under the impression that none of the source (apart from JavaScript maybe) wouldn't be openly distributed with the app, but compiled or packed inside the application somehow (note the .cpp file and the qml directory)?

Update 2

The application works just fine when run from inside Qt 5 Creator:

Starting [...]\test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\test.exe...
QOpenGLShader::link: "(41,18): warning X3206: implicit truncation of vector type

" 
[...]\test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\test.exe exited with code 0

Well, apart from that one awkward warning...

Upvotes: 3

Views: 4850

Answers (1)

Nemanja Boric
Nemanja Boric

Reputation: 22157

You need to copy qml files into your current directory. When you create release application with QtCreator, you will have this directory structure (or something like this):

example-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release
  |-     debug
  |-     qml
  |-     release // application executable is here

What you need to do is to copy qml folder to be in the same directory with your executable release file (simply copy qml folder into release folder).

About dll files - you can copy them manually from QtInstallDir/bin folder or you can add that directory into PATH, if you are developing on that machine - it could be easier.

You don't need to publish cpp files, but you need to publish qml files. What you can do, through I never succeed, but it seems to be possible is to bundle qml files into Resource file, and to load it from resources, but that can be extracted easily, too - so - don't put your logic or confidential informations in qml files.

Also, you need to copy all required dll files into directory with exe: qt5quick.dll, qt5gui.dll, qt5core.dll and libEGL.dll.

Upvotes: 3

Related Questions