How to Force My Application to Open One Exe Only? Qt, Linux

Qt application - open one process only

Even if you don't want to, QtSingleApplication is what works. If you want to learn how it is implemented, you can always read the source code.

Single setup exe file Qt Application deployment

==>Static Compilation for Windows -

https://www.youtube.com/watch?v=lwX_urJJOf8

==>Static Compilation for Mac/Linux -

https://retifrav.github.io/blog/2018/02/17/build-qt-statically/

How to run my application without QTCreator?

When you deploying your app using windeployqt default is release build, so if you want to deploy the debug version of libs (the ones with 'd' at the end) you have to pass --debug parameter.

You should never mix programs compiled as Release version with debug libs and Debug version with release libs. Debug libs have some extra code and they're not compatible with each other.

When you use MinGW, you may also need to copy libgcc_s_dw2-1.dll, libstdc++-6.dll and libwinpthread-1.dll from qtfolder/5.9/mingw.../bin to your exe folder.

Unable to run application outside qt

QtCreator keeps an internal environment path for qt libraries. To run your "HelloWorld.exe" you can just copy missing dlls from qt/bin to the same folder with the executable. A better solution would be adding qt/bin to system path from environment variables.

If you are planning on distributing your application, the best solution is to link qt libraries statically instead of dynamically. You can learn more about his option from:

How to make Qt and Qtcreator link the libraries statically instead of dynamic?

Run another executable in my Qt app

My fault was in the path to executable.

I edit it, very simple and got it work.

QApplication a(argc, argv);
MainWindow w;
w.show();
QProcess P(&w);
QString programPath;
programPath=
"/home/erfan/Documents/Qt/test1-build-desktop- Qt_4_8_1_in_PATH__System__Release/test1";
P.start(programPath);
return a.exec();

And it work properly.

Another way is to put the executable directly in root:

(/ somthings)

opening an exe file in c++ form

Possible some of application components not founded by executable file. For simple case QProcess::setWorkingDirectory( /* executable directory */ ) can help.
In bad case check environment variables of process in your run. You can loss paths to required libraries.



Related Topics



Leave a reply



Submit