简体   繁体   English

无法在Visual Studio 2012中打开头文件

[英]Cannot open header file in Visual Studio 2012

I am using Visual Studio 2012 and trying to import header files in the project, but have been failing miserably. 我正在使用Visual Studio 2012并尝试在项目中导入头文件,但是失败很惨。 Here is what I have tried to do: 这是我尝试做的事情:

#include "gevents.h"
#include "gobjects.h"
#include "gwindow.h"

int main(){

     int x=1;

     return 0;
}

I have added these three header files in the project location: C:\\Users\\Shaby\\Documents\\Visual Studio 2012\\Projects\\ConsoleApplication39 我在项目位置添加了这三个头文件:C:\\ Users \\ Shaby \\ Documents \\ Visual Studio 2012 \\ Projects \\ ConsoleApplication39

In addition, I have also gone to Project properties ->Configuration Propertues -> C/C++ ->General and included the above path location in "Additional Include Directories" but this had yielded nothing. 另外,我还转到了项目属性->配置属性-> C / C ++->常规,并将上述路径位置包括在“其他包含目录”中,但这没有产生任何效果。 Instead, I am getting the following error: 相反,我收到以下错误:

Unable to start program C:\\Users\\Shaby\\Documents\\Visual Studio 2012\\Projects\\ConsoleApplication39\\Debug\\ConsoleApplication39.exe The system cannot find the file specified 无法启动程序C:\\ Users \\ Shaby \\ Documents \\ Visual Studio 2012 \\ Projects \\ ConsoleApplication39 \\ Debug \\ ConsoleApplication39.exe系统找不到指定的文件

@Usman Khan , I have one solution for your problem.In Solution Explorer Window (if not opened then press Ctrl+Alt+l ) you can see you project name.Right click on it and than Add > Existing Item . @Usman Khan,我有一个解决您的问题的方法。在“解决方案资源管理器”窗口中(如果未打开,请按Ctrl+Alt+l ),您可以看到您的项目名称。右键单击它,然后单击“ Add > Existing Item Now select your header files which you want to include & press Add . 现在,选择要包括的头文件,然后按Add Done :) . 完成:)。

why are you making it complex, just keep it simple.After creating your project. 为什么要使其复杂,只需保持简单即可。创建项目后。 Open solution explorer. 开放式解决方案资源管理器。 Under your project name you would see a folder "header files" , add your header files in it (your header files should have ".h" extension) and then to use them include them in your source files 在您的项目名称下,您将看到一个文件夹“ header files”,在其中添加您的头文件(您的头文件应具有“ .h”扩展名),然后使用它们将它们包括在您的源文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM