In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the Qt creator project construction configuration and running settings is how, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Using the Qt Creator integrated development environment to build and run programs is a very simple thing, a button or a shortcut to do it all, everyone already knows. But what's going on behind these seemingly simple processes?
Click the Qt Creator project mode to see the configuration interface of the current project:
Qt Creator's project mode becomes available only after you open a specific project. For open projects, such as the HelloWorld project, the configurable content is shown in the five categories shown on the left side of the figure above, namely, "Build & Run", "Editor", "Code style", "dependency" and "Clang Static Analyzer (Clang static Analysis)", and the most commonly used is "Build & Run".
For each Qt suite, you can configure the build-time environment, commands, and runtime environments, and commands separately. If you need to attach command parameters to the generated executable program such as * .exe, you can click the "Run" setting under the name of the Qt suite to attach parameters to the executable program. Let's focus on the "Build" setting.
In the "Build" setting, you can select the build type (Debug, Release, or Profile) in the combo box above, and you can add your own new build type (usually unnecessary).
Shadow Construction (Shadow build)
Next, in the Summary, Qt Creator uses shadow build (Shadow build) by default, which builds the project by putting the intermediate files and target programs in a separate build directory, realizing the complete separation of the source code directory and the build directory, which is very convenient for the release of the program source code and will not mix up the intermediate files during the build process.
For the project HelloWorld, its source code path is D:\ QtDemo\ HelloWorld, while the shadow build directory in the figure above is in D:\ QtDemo\ build-HelloWorld-Desktop_Qt_5_9_0_MinGW_32bit-Debug, and the source and build folders are in the parent folder QtDemo.
The naming rule for the shadow build directory is: build- project name-build suite name-build type. The project name of the demonstration is HelloWorld, the package name is Desktop Qt 5.9.0 MinGW 32bit, and the build type is Debug. The synthesized build directory cannot contain spaces and periods, so replace the spaces and periods with underscores to get build-HelloWorld-Desktop_Qt_5_9_0_MinGW_32bit-Debug. The intermediate files generated during the project build and the final target program can be found in the shadow build directory.
Construction steps
Then there is the "build step", which mentioned the three axes of the qmake compiler, because the pro file has been generated by Qt Creator, so the compiler only needs the remaining two axes:
① uses qmake to generate Makefile to the build directory
② executes make (mingw32-make) in the build directory.
For the details of these two axes, you can click on the details on the right of the qmake and Make lines. There is no additional screenshot here, just explain the option parameters of the qmake command in the figure above:
The-r option means to recursively check the project folder
-spec win32-g++ option parameter refers to the use of win32-g++ custom scripts to generate Makefile. Different custom scripts are used for different compilers and operating system platforms. Win32-g++ is a custom script specifically for the Windows system MinGW compilation environment (the actual custom scripts are located in the QTDIR/mkspecs/win32-g++ folder)
"CONFIG+=debug" refers to the target program that generates the debug type, and for the optimized distribution, it corresponds to "CONFIG+=release". If neither of these CONFIG is added, then the target program of release type is generated by default.
View the actual situation of the project build and project runtime
A brief introduction to these settings for the Qt project build, let's take a look at the actual situation about the project build and the project runtime. Go back to Qt Creator editing mode and click the "compile output" panel in the bottom output panel to see the compile and link commands in the process of generating the project:
The compile link command that Qt Creator actually uses is much more complex than the compile link command we demonstrated earlier, using extremely compact commands. If there is nothing wrong with the compilation link of the project, don't worry too much about what is in the "compile output" panel. If the compilation link goes wrong, you need to check the problem in the "compile output" panel. Although the Qt Creator compilation link command is complex, the general process is similar to the last generation process diagram of "the use of Qt .ui files."
Compared with the compile output panel, the Application output panel is more commonly used, and Qt Creator captures and displays the output of debugging information, printing to the command line, and so on, as shown in the following figure:
There are also some small buttons in the title bar of the Application output panel, which interested readers can try for themselves, with quick functions such as emptying the output, rerunning the program, and stopping the currently running program.
Run Settin
Finally, explain the running environment of the target program. If you want to add command-line parameters to the generated target program from the integrated development environment, you need to use the "run settings" of the project mode:
Click the "Run" button to enter the running configuration interface, where you can see several key paths and parameter settings in the figure above:
Path / parameter description
Executable executable program path, or target program path. The generated exe file is D:\ QtDemo\ build-HelloWorld-Desktop_Qt_5_9_0_MinGW_32bit-Debug\ debug\ HelloWorld.exe. If you enter this path and run the exe file directly, then the exe file cannot run properly by default because of the lack of dynamic libraries and environment variables that the runtime depends on. You need to start the Qt command line from the start menu, and then start exe from the command line to function properly.
The command-line argument of the Command line arguments target program, which can be manually added here, so that it will be appended every time Qt Creator starts the target program.
Working directory target program work path, it should be noted here that the target program starts neither from the source code path nor from its own executable path, but from the work path, which is the same as the shadow build path by default. Therefore, if you use a relative path to manipulate a file in your program code, such as "data.db", then the file should be placed in the working path so that the file in the relative path can be found when the target program starts from Qt Creator.
Another important setting in the run settings is Run Environment. For the setting of runtime environment variables, we mark the important variables as follows:
Readers are generally familiar with the PATH environment variable, which is the path of a large number of executable programs *. Exe and dependent libraries *. Dll. When the program starts, it will find the dependent dll from the PATH environment variable and load it. Qt has also added its own dependent library path for PATH, with three new paths:
D:\ Qt\ 5.9\ mingw53_32\ lib
D:\ Qt\ 5.9\ mingw53_32\ bin
D:\ Qt\ Tools\ mingw530_32\ bin
The first is the path of the compile-time dependent library, the second is the executable program and dynamic library path of the Qt library itself, and the third is the executable program and dynamic library path of the MinGW compilation environment.
In addition to PATH environment variables, Qt library-specific QTDIR environment variables are also very important. Qt programs run not only rely on *. Dll, but also rely on plug-ins, translation files, settings files, etc., in the Qt library. QTDIR is the total directory of the Qt library, according to which the Qt program automatically looks for subfolders, and the subfolders will contain other things that the Qt program depends on when it runs.
If the reader wants to integrate Qt's dependent libraries into the operating system's environment variables, set not only PATH, but also the correct QTDIR. QTIDR is usually the parent folder of the folder where qmake.exe is located. For example, if qmake.exe is located at D:\ Qt\ 5.9\ mingw53_32\ bin, then QTDIR is D:\ Qt\ 5.9\ mingw53_32.
Thank you for reading this article carefully. I hope the article "what is the project construction configuration and running settings in Qt creator" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.