Visual Studio 2015 create standalone release application



  • Hi all. I'm new in QT development. I've created a QT console application using Visual Studio 2015 and specific addIn that allow to create QT project in visual studio.
    In visual studio, QT option I've set QT folder (C.\C:\Qt\5.9.1\msvc2015_64) and write my app: EVERYTHING WORKS GOOD inside visual studio!
    After, i've compiled my app in release and try to launch (outside visual studio) exe manually: I've error because miss 2 QT dlls; I've copied manually the 2 dll in exe path and EVERITHING WORKS GOOD.

    After I've tried to rename QT folder path (where visual studio was linked), then I launch exe: i've no "miss dll" message, but result is not as expected!!! seems that need some dlls.

    So, how can create a package with all needed dlls using visual studio 2015?

    Thanks


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you saying that it's not expected that your console application works with only two of Qt's dlls ?

    Your application only needs what it is currently using and the matching VS runtime.

    If you are thinking about more complicated setups, that's usually because it involves a GUI which requires the platform plugin for your application to run.



  • sorry, I've explained not so good.
    I give you 2 examples:
    Consider that I've compiled my app on my pc, with visual studio 2015 (where I've configured the QT folder path): it generates exe..
    consider that I run my exe in another pc: it fails because requires 2 QT dlls..than I copy the 2 required dll in exe folder: no error message of miss dll, but my app doesn't work as expected.

    So, now I make the same test on my pc where I builded my exe: I've no problem on my PC where there is QT folder configured on visual studio QT ADDIN setup:
    Indeed, I run my app clicking on generated exe , inside the exe folder there are the 2 dlls too (so, no miss dlls message will be), and result is as expected (different of other pc where doesn't work).
    But if for example I make this test: I rename in my pc (where before everything works good) the QT folder, then I run my exe, BUT NOW my app doesn't give results as expected (like the other pc)..seems as the exe need the original QT folder (that has different path respect of exe path, on which there are only the 2 copied dlls) that was set up on visual studio when exe was builded.
    I don't understand


  • Lifetime Qt Champion

    What are you expecting and what is happening exactly ?



  • OK..
    I've created a very easy application that load an image in QImage and print its width and height.
    Please download my package that contains original visual studio solution and a folder with builded exe and needed QT dlls:
    https://www.dropbox.com/s/2pvi1r195croebx/QTExample.zip?dl=0

    In visual studio environment I have set the full path of my QT folder (where there are bin, libs, include, etc etc):
    0_1505468599132_10.jpg
    0_1505468631700_20.JPG

    In the second image you can read my code and the QT full path that I have set in visual studio environment.

    If I run my project from visual studio (in debug and release), result show correctly width and height of image.
    0_1505469656216_70.JPG
    After, I took builded exe and copied it in a folder, with aldo needed dlls taken from C:\Qt\5.9.1\msvc2015_64\bin
    0_1505468978788_30.JPG

    If I run QTExample.exe, everything works correctly: the correct image width and height is shown.
    0_1505469050876_40.JPG

    Now, I make this experiment; rename the QT folder (the one set in visual studio, as shown before):
    0_1505469108626_50.jpg

    If i try to run QTExample.exe, it doesn't work: it show 0,0 as image size...the behavior is the same if I execute my exe in another pc where there isn't QT full folder (or where path is different)
    0_1505469196796_60.JPG

    Seems like my exe expects that the QT folder set in visual studio environment is existing and contains all required files.

    Can you help me please?


  • Lifetime Qt Champion

    You are missing the image plugins in your distribution.

    You can use windeployqt to help with deployment.



  • thanks!
    I've solved copying folder "imageformats" (that I can find in C:\Qt\5.9.1\msvc2015_64\plugins ) inside exe folder.
    If I copy full folder "plugins" doesn't work...if I copy just all dlls inside exe folder doesn't work...but If I copy only "imageformats" forlder it works!
    0_1505485367119_80.JPG


  • Lifetime Qt Champion

    Glad you got it working and thanks for sharing.

    Since you have it running now, please mark the thread as solved using the "Topic Tools" button so that other form users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.