简体   繁体   中英

Launch Qt application from batch file

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM