I am using Qt creator and its compiler minGW, I want to compile .cpp (//which is created not using Qt)file using this Qt creator compiler in CMD
need compiling information in cmd using Qt creator
c:>c:>c:\Qt\Qt6.2.6\Tools\mingw1120_64\bin gcc -o c:\Users\chandresh.bs\Desktop\CplusApp\Hello.cpp Hello Access is denied.
c:>c:>c:\Qt\Qt6.2.6\Tools\mingw1120_64\bin g++ -o c:\Users\chandresh.bs\Desktop\CplusApp\Hello.cpp Hello Access is denied.
Firstly, you have to understand mingw-g++ compiler flags. The most simplest example of compiling using g++ is
g++ hello.cpp -o hello.exe
In this example, hello.cpp
is your file, flag -o
tells to compiler that after this flag you provide name of executable. You are using Qt, so this example will not be able to compile your project. You need to link your project against Qt libraries. There's a lot of libraries and it will be quite difficult to do using only compiler.
Any project with big amount of libraries and files uses some build system.You write configuration file for your build system, after that you generate Makefile
or something like this, and using make
you can compile it. It's pretty simple to use, because you don't need to remember flags, write long commands to compile something. Also, build system helps you to make your code cross-platform, because it can be used on any OS. For this purposes, Qt uses qmake, that do all necessary things and let you compile project with one click in Qt Creator. You can simply use qmake generated in Qt Creator:
build
in your project foldercd your-project-folder
qmake project_name.pro
make
It's simpler than linking anything for every file you have. Hope it will help you!