A Qt project typically has some source files, header files, and a .pro file(project file) in a directory. If you copy a whole project directory that has been built to another location and try to build the project in the new location, you may encounter some problem. You will find the building outputs such as the .obj files and the .exe file are put in the old location where you built the old project directory. On the Options window of Qt creator, you will see the project directory is set to the current location, and the default build directory is set to “../build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}”. It seems the build directory is now under the same parent directory of the new project directory. Why the output directory is not changed? This is because when you copied the project directory, a file called .pro.user was also copied without any change. This file stores the information like build directory when you built the old project. To update the build directory, you should delete this file and re-open Qt creator. Now Qt creator hints you to configure project. After configuring the project, you can find the .pro.user file is re-generated in the new project folder, which includes the new build directory(as the value of the key ProjectExplorer.BuildConfiguration.BuildDirectory). When building the new project, Qt Creator will use the information in the .pro.user to determine where to output.
When you start to run the program in Qt Creator, what is the working directory for the running application? It is not the current project directory. It is not the directory where the exe file resides, either. In fact, the working directory is set to the build directory.
Comments are closed, but trackbacks and pingbacks are open.