VS默认的文件存放非常乱,以一个helloworld程序为例:
最开始创建好项目,注意一个解决方案下可以有多个项目
其文件目录还是很干净的:
解决方案(Solution)对应的文件夹:
项目(HelloWorld)对应的文件夹
但是当我们通过不同平台编译文件后,
全来一遍,一共4种不同方式后
文件就会很乱:
其中Debug和Release都是指x86下的,而x64下还分为Debug和Release
这明显是很不符合人的直觉的~
解决方案(Solution)对应的文件夹,这里多出来的文件是项目产生的可执行文件
项目(HelloWorld)对应的文件夹,这里多出来的文件是生成的中间、临时文件,并且它们的分布很凌乱
所以我们需要为其进行配置,让它的文件输出更加合理,也方便我们进行项目管理~
我们希望,所有的可执行文件都在bin目录下,所有的中间、临时文件都在temp目录下(也可以自定义)
First select the property page corresponding to the project , select the configuration as all configurations, and select the platform as all platforms.
Note: each project must be configured in this way, just copy and paste it~ What
we want to configure is the following two items
. Set them as follows respectively.
$(SolutionDir)./bin/$(Platform)/$(Configuration)\
$(SolutionDir)./temp/$(Platform)/$(Configuration)/$(ProjectName)\
Explain here:
SolutionDir refers to the folder where the solution is located
Platform refers to different platforms (Win32\x64)
Configuration refers to the number of executable files (x86, x64)
ProjectName refers to the project name
After making the settings, we then compile in four ways, as
you can see, the directory is very clear.
Because C\C++ is binary compatible at the source code level, when we provide files, we only need to package the corresponding projects, and bin and temp are unnecessary (if only executable files are packaged bins), this greatly improves the manageability of the project.
Note here that the above writing method is not unique. The reason why ProjectName is added to temp is to avoid conflicts in intermediate files, and bin can also add ProjectName, but because different projects under the same solution often depend on the same dll, so generally we put executable programs together~ The contents of the bin file are as follows: the directory is
very
clear
The contents of the temp directory are as follows:
You can see that different projects have different folders
Then we create another project
and pay attention to reconfiguring this project, just copy and paste.
Different projects are under the same solution
and then compiled in 4 ways.
You can see that the executable files are all in one folder,
and the intermediate and temporary files have different folders for each project.
End~