Setting up environment, deployment.
-
I have been building and running the project I'm working on entirely in Qt Creator, I've sent the application to a colleague and he is having difficultly running from the command line.
I created a deployment folder using windeployqt, and whilst this contains folders and dll's there is nothing in this folder to add set-up of a target system.
What is required to make the dll's and drivers in this produced folder useful and visible to the application when run from the command line?
-
Hi,
There's nothing special to do as on Windows the application is the first folder searched for libraries.
What exactly happens to your tester ?
-
@SGaist , thank you for the reply, I'm trying this on the laptop I'm using to develop on which has a full installation of Qt Creator.
On Windows version 10.0.19041.1052, with Qt 5.9.2, I open a command prompt and go to the folder where the executable was built:
C:\Users\simon.platten\Documents\vehicle-training-setup-application\build-training-server-application-Desktop_Qt_5_9_2_MSVC2015_32bit-Debug\debug
I then try to launch the executable:
trngServer QMYSQL localhost training trainer Password
The result is 4 dialogs displayed one after the other:
-
@SPlatten said in Setting up environment, deployment.:
On Windows version 10.0.19041.1052, with Qt 5.9.2, I open a command prompt and go to the folder where the executable was built:
This cannot work, you have to use windeployqt.exe to copy all shared libraries locally.
cf https://doc.qt.io/qt-5/windows-deployment.html or https://wiki.qt.io/Deploy_an_Application_on_Windows
-
@KroMignon , sorry, the windeployqt is only used to create the install folder for systems that are not the development laptop, it was not used on this laptop.
However this is the issue I have, I can run the executable from Qt Creator but not in a command prompt.
-
@SPlatten said in Setting up environment, deployment.:
However this is the issue I have, I can run the executable from Qt Creator but not in a command prompt.
This is normal, Qt Creator will setup environment variable to point to shared libraries before starting application.
When starting from command prompt, you have to do it yourself. -
@SPlatten if you don't want to provide the dlls locally, than you have to add them to the path, preferably not the global one, but the local one in the command prompt
Take a look into the project settings in QtCreator check the build environment, check the path and compare it to the one set in the cmd prompt and append accordingly
-
@SPlatten said in Setting up environment, deployment.:
thank you, I thought that Qt Creator would have done that as part of the installation, obviously not.
There is not reason to change WINDOWS path.
Qt Creator will only update WINDOWS environment settings before starting the application. This is enough.By the way, why do you want to launch it from the build path and don't start it from QtCreator?
-
@SPlatten said in Setting up environment, deployment.:
@KroMignon , for testing purpose's, I'm sent the application to someone else to test and I wanted to be sure it would work locally outside of Qt Creator.
than use the deployment tool, thats what it is for :D
anyway inside your bin folder of your qt installation , there's a qtenv.bat if you execute that inside your cmd prompt, it should set up the environment correctly (locally)
-
@SPlatten said in Setting up environment, deployment.:
I wanted to be sure it would work locally outside of Qt Creator.
So you should try out the deployment result, not the build result ;)
You need to use windeployqt.exe or CQtDeployer.
-
@SPlatten said in Setting up environment, deployment.:
now your confusing me, as I said I'm trying to run it locally, the deployment tool as I've been told is not for local use.
I try to be more explicit:
- Qt libraries (and also MSVC libraries) are shared libraries. On Windows they need to be on application directory or accessible through PATH settings
- Qt also uses plugin (like graphic, sound, network, etc.) which needs to be locally or accessible via QT_PLUGIN_PATH
Because you could have many Qt Version installed on you development machine, it don't make sense to set add Qt libraires path into PATH environment. This will be done by QtCreator before starting application.
If you want to deploy the application, you have to used a deployment tool which will copy the required DLL.