如何在Visual Studio C ++ 2012中创建文件夹 [英] How to create a folder in Visual Studio C++ 2012

查看:183
本文介绍了如何在Visual Studio C ++ 2012中创建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C ++的Visual Studio 2012开始了我的第一个更大的项目。我将在文件夹中构建源文件,但是找不到在哪里可以创建真实文件夹,例如在Windows资源管理器中。所以这是我的问题。

I have started my first bigger project with Visual Studio 2012 in C++. I will structure my Source-files in folders, but I can not find where I can create real folders, like in the windows explorer. So here is my question.

如何在项目中创建真实文件夹?

How can I create real folders in my project?

推荐答案

IDE为此提供了一个命令 New Folder。它甚至出现在项目+添加上下文菜单中,使用工具+定制查看上下文菜单时可以看到一些内容。但是,它隐藏在C ++ IDE中。

The IDE has a command for that, "New Folder". It is even present in the Project + Add context menu, something you can see when you look at the context menu with Tools + Customize. It is however hidden in the C++ IDE. Intentionally.

重要的是要理解为什么隐藏它。这样可以避免麻烦,而在使用Explorer创建文件夹时会遇到麻烦。

Its important to understand why it is hidden. It keeps you out of trouble, the kind of trouble you'll get into when you create folders with Explorer.

问题所在是C ++文件的生成方式。编译完成后,它们会生成一个.obj文件。该obj文件存储在名称为项目设置的目录中。您可以通过项目+属性,常规,中间目录设置来查看它。对于单个.cpp文件,它是C / C ++,输出文件,目标文件名。该默认值是 $(IntDir)宏,该宏告诉编译器使用中间目录设置。使用默认设置,用于Debug构建的所有.obj文件最终都位于Debug子目录中。 Release版本的Release子目录。不管.cpp的存储位置。

At issue is the way C++ files get built. They produce an .obj file when the compiler is done with them. That obj file is stored in a directory whose name is a project setting. You see it with Project + Properties, General, Intermediate Directory setting. For an individual .cpp file, it is C/C++, Output Files, Object File Name. The default for that one is $(IntDir) a macro that tells the compiler to use the Intermediate Directory setting. With the default settings, all .obj files for the Debug build end up in the Debug subdirectory. Release subdirectory for the Release build. Regardless where the .cpp was stored.

也许您现在看到了陷阱。如果您使用.cpp文件创建子目录,则该子目录中的.cpp文件的名称与另一个子目录中的另一个.cpp文件相同时,您会遇到麻烦。它们产生一个具有相同名称的.obj文件。一个覆盖另一个,最后一个被编译。这会产生非常神秘的链接器错误。您将得到重复的符号错误,因为最后一次构建的.obj文件被链接了两次,并且丢失了覆盖的.obj文件的符号错误。

Maybe you see the bear trap by now. If you create a subdirectory with .cpp files then you'll get in trouble when that subdirectory has a .cpp file whose name is identical to another .cpp file in another subdirectory. They produce an .obj file with the same name. One overwrites the other, which ever one was compiled last. That produces very mystifying linker errors. You'll get duplicate symbol errors because the last built .obj file is linked twice and missing symbol errors for the overwritten .obj file.

因此,继续创建一个子目录但是要当心这个问题。如果发生这种冲突,则必须更改.cpp文件的对象文件名设置。

So go ahead and create a subdirectory but beware this problem. You have to change the Object File Name setting for the .cpp file if such a collision happens.

这篇关于如何在Visual Studio C ++ 2012中创建文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆