[Solved] Qt 5.0.1 + MSVC2010 desktop app deployment
I'm pretty new to Qt and C++ is not my primary programming language (hence the lame questions). I'm developing an application which uses third party libraries (OpenCV) - linked by LIBS statement in my .pro file. I need to deploy the application - so I built it in release mode, added all the required Qt dlls, the platform and plugins directories, I even added the @CONFIG += embed_manifest_exe@ statement (a part of solution to a similar problem I found ont he web). But when I try to run it outside IDE, nothing happens, no error or anything (that drives me mad, really).
I realize this is a pretty common issue, but I tried all the solutions suggested and nothing worked for me. "This page":http://qt-project.org/doc/qt-4.8/deployment-windows.html suggests building it from command line - how exactly can I do that? How do I add set the Qt variables? There is no command line exe in my Qt folder. There is a "Deploy" option in QtCreator, but it's always diabled.
Please, could you help me, step by step, how can I deploy my app, so that it runs outside QtCreator?
Hi and welcome to devnet,
This question has been asked many times on the forum. First thing to do is look at the "Windows deployment guide":http://qt-project.org/doc/qt-5.0/qtdoc/deployment-windows.html
If you had read the post, you would have known I have already found this guide and it was not actually helpful.
It refers to command line commands which I do not know how to access. (No command line shortcut in my Qt folder, Visual Studio Command line does not include command "configure".) Is there any way how to avoid using command line?
It's indeed the VS command line. There's no configure script in the pre-built Qt. You need the sources for that. You can either get them using the installer or download them from the Qt project site.
Currently you shouldn't need to rebuild Qt. However if you really want to, I would recommend using 5.2 and no you can't avoid the command line but again, you shouldn't need to do that.
Now back to your problem:
- Did you took the dlls from the Qt library dir and not from Qt Creator dir ?
- Did you put the platform folder in the same folder as your exec and not in plugin ?
- Does your program do any check on startup and end early ?
Thanks for replying, I copied the dlls (Qt5Widges, Qt5Gui and so on) from Qt folder (Qt 5.0.1\5.0.1\msvc2010\bin to be exact) and put them in the same directory where the exe file is placed. I placed also subdirectories "platforms" and "imageformats" there, although I'm not sure it helps at all.
I'm not exactly clear on what you mean by check on startup, when I run the exe file (from command line, by clicking or when I run in admin mode, I tried everything) it just does nothing, nothing happens.
Thanks again for taking your time to help me.
Sure platform will help, image formats should go in a plugins subfolder.
By check I meant you could be looking for some configuration/resources and if not available stop you program there.
What type of application is it ? Widget based ? QML ? OpenGL ?
It's a widget based Qt GUI app, I utilize some of the OpenCV libraries, but that's all.
The app does not load any external resources after startup, so even if they were missing, that should not cause problems - I only work with some image files, but not right after the app starts.
I figured that by adding the libraries like this:
@LIBS += -LC:\opencv\build\x86\vc10\lib
it is not necessary to add them as dlls later and that they should be linked statically. Can these libraries cause these problems?
Unless you are linking to the static version of OpenCV you will need to copy the dlls besides your application or have them in your PATH environment variable.
One thing you can to is to check your application with Dependency Walker to see whether you have something missing (which should yield a crash unless it's a plugin not loaded)
Ok, so I copied the OpenCV dlls corresponding to the libs I added to my .pro file to the exe file directory, nothing happens.
Dependency walker shows:
@Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
There are a few modules with red-ish icons with names like
is it a problem? What can be the cause?
No, these ones are not a concern.
Can you show a picture or write down how your current application folder looks like ?
Ok, my app folder looks like this:
The platforms folder:
To be honest, I copied everything, out of desperation, hoping that I could erase the stuff I do not need later.
Sorry, the complete contents off app folder after I added the opencv libs:
Silly question but… Is this in the release build folder ?
Yes, it's in the release build folder.
Which installer of Qt did you use ?
Also, why not update to a more recent version ? Current stable is 5.1.1 and 5.2 is almost out.
Desktop Qt 5.0.1 MSVC2010 32bit. I didn´t keep track of the current versions, but ok, I'll update the Qt and see what happens.
IIRC, it means that it's an ANGLE build, I don't know whether this can play a role when also using OpenCV.
If it doesn't get better, just build a default widget project and try to make it run. Doing so you'll be sure that it can start properly on your computer
OH GOD IT ACTUALLY WORKS!
I built it using Qt 5.1.1 and placed the new version dlls in the release folder and it works! You are my hero! Thanks a million!
You're welcome !
Since now you have everything working, please, update the thread title prepending [solved] so other forum users may know a solution has been found :)