0

I have developed an application in Qt and outside Qt Creator, when I run this application, it works. But when I use a batch-file to execute the application I get this error:

The application failed to start because it could not find or load the Qt platform plugin "Windows

I have included all the dll including platform/qwindows.dll, but I cannot understand what the problem is. Any idea what could be wrong?

Before, I thought that I have used an external library which is not set properly, but after removing the external library for testing purpose, the problem persists.

The contents of the batch files are:

@echo off

set VMT=\\serverName\DEV
set BC_VERSION=v1.0

echo Test release of BeamConfigurator %BC_VERSION%

set BC_HOMEDIR=%VISMT%\BeamConfigurator\%BC_VERSION%
set BC_BINDIR=%ABC_HOMEDIR%\bin

echo %BC_BINDIR%

start /WAIT /B /LOW %BC_BINDIR%\BeamConfigurator.exe
honk
  • 9,137
  • 11
  • 75
  • 83
user1703942
  • 317
  • 3
  • 15
  • Can you please provide your batch file? – Alexander Sorokin Sep 17 '15 at 10:10
  • your current working directory when your batch file starts the Qt app executable is not the directory where "platform" folder is located, so Qt app can't find it. – Max Go Sep 17 '15 at 10:29
  • @N1ghtLight: The platforms/windows is in the same folder as executable. – user1703942 Sep 17 '15 at 11:15
  • @user1703942, but what's the folder from where you launch your batch? how do you launch it? – Max Go Sep 17 '15 at 11:19
  • If you are talking about location of the batch file, then the batch file is not in the same folder as executable and dll. It is on another location in the server. And this procedure has worked for other Qt applications. Position of the batch file and executables are Beamconfiguration/bin/Beamconfiguration.exe Beamconfiguration/Script/test.bat – user1703942 Sep 17 '15 at 11:24
  • How do you think than your Qt app will find your "windows" directory? :) – Max Go Sep 17 '15 at 11:26
  • try manually copy whole "windows" folder to the folder from where you launches your batch file. and try to run batch file. if your do this from cmd.exe make sure that your current directory is the folder with batch file too. – Max Go Sep 17 '15 at 11:27
  • I tried, it did not work. Also, if Qt App finds other dll in the different folder, it should find the windows directory at the same path. – user1703942 Sep 17 '15 at 11:34
  • yes, your are right here,,,, it seems you have wrong title of folder `platform` ... it should be 'platforms'. – Max Go Sep 17 '15 at 11:42
  • another reason why is it happen is that you missed to copy some of the other Qt dlls on which the dlls in platforms folder are depend. – Max Go Sep 17 '15 at 11:46
  • It is actually 'platforms', and I think if it misses any other dll, it will not launch the application by clicking on it. As i get this error message when i launch the same application using a batch file. – user1703942 Sep 17 '15 at 11:52
  • I think the mistake is here: `%ABC_HOMEDIR%` and in also `%VISMT%` not to mention the variables not in quotes. – Paul Sep 17 '15 at 19:20
  • @Paul: That was a typing error while posting here otherwise It was VISMT. – user1703942 Sep 18 '15 at 11:55

2 Answers2

1

It looks like your executable is trying to access the hardcoded (which Qt Creator does) library paths. If you have copied all the dll files required to run your executable to the same directory as your executable, try this.

Create a file named qt.conf and place it in the same directory as your executable. Add the required stuff like this.

[Paths]
Prefix = /some/path
Translations = i18n
Plugins = plugins

More info can be found here

ramtheconqueror
  • 1,907
  • 1
  • 22
  • 35
1

The problem was that one of my colleague had added the following line in the main function while testing something.

QCoreApplication::addLibraryPath("./");

After removing this line, it started to work with the batch file. But i still did not understand why there was a problem only when we launched it from the batch file. even though i had put the batch file in the same folder as executable.

user1703942
  • 317
  • 3
  • 15