Creating project executable and passing command line argument
-
Hi,
I have created the project in linux. Now i want to create executable of this and has to pass two arguments from command line which will be used in program.
Ex: ./executablename <arg1><arg2>
How this can be achieved. Kindly suggest.Regards,
Anuj -
Hi
i assume you mean when you run the .exe ?
You can use
http://doc.qt.io/qt-5/qcommandlineparser.htmlNormal c++ handling is also possible
int main(int argc, char *argv[])argv contains the arguments as normal.
-
Hi
i assume you mean when you run the .exe ?
You can use
http://doc.qt.io/qt-5/qcommandlineparser.htmlNormal c++ handling is also possible
int main(int argc, char *argv[])argv contains the arguments as normal.
@mrjj Hi,
Like in c... we complie and create exetuable. Like that, how can this be created for qt project?
Thanks in advance... -
@mrjj Hi,
Like in c... we complie and create exetuable. Like that, how can this be created for qt project?
Thanks in advance...@anuj-nogja
Hi
Just select the Release kit and build all.
Then there is an exe in the build folder.To run it on other system, you need some DLLS with it.
That we call a deployment folder.
You can use the tool
http://doc.qt.io/qt-5/windows-deployment.html
to help collect the needed dlls for the exe.The .exe CANNOT run without these DLLs in the folder when outside Creator
-
@mrjj Hi,
Like in c... we complie and create exetuable. Like that, how can this be created for qt project?
Thanks in advance...@anuj-nogja said in Creating project executable and passing command line argument:
Like in c... we complie and create exetuable. Like that, how can this be created for qt project?
A Qt project is a C++ project. If you use Qt Creator, you compile & create an executable from there, just as you would for any other C project.... Or you can do it all externally from the command-line. There's nothing special for Qt here.
-
If you are wondering how add command-line arguments when you run the program from QtCreator; select 'Projects' on the left and then the 'Run' settings for the kit you are building with. One of the options that you can set is the command-line arguments. This is useful for testing your program while developing it and before deploying and distributing it.