如何在Visual Studio 2008中包括头文件? [英] How to include header files in Visual Studio 2008?

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

问题描述

我目前正在尝试编译一个包含两个头文件的简单程序。我在解决方案资源管理器中看到它们,我通过包括现有文件包括它们。但是,当我运行我的程序,它得到以下错误。
致命错误C1083:无法打开包含文件:'FileWrite.h':没有此类文件或目录。问题是,我看到文件包括在头文件夹和代码我写了:

I am currently trying to compile a simple program that includes two header files. I see them in the Solution Explorer, where I included them through "include existing files". However, when I run my program it get the following error. fatal error C1083: Cannot open include file: 'FileWrite.h': No such file or directory. THe problem is that I see the file included in the Header's folder and in the code I have written:

#include "FileWrite.h"

,然后剩下程序代码。
是否还有其他需要做的事情,编译器可以看到头文件,并链接到.cpp文件我试图编译?

and then the rest of the program code. Is there something else needed to do so that the compiler can see the header file and link it to the .cpp file I'm trying to compile?

推荐答案

如果您在代码中写入 #includeFileWrite.h你需要确保编译器可以找到该文件。有三个选项:

If you write in your code something like #include "FileWrite.h" you need to make sure compiler can find that file. There are three options:


  • FileWrite.h应与源代码文件(.cpp)或

  • 该头文件的路径应该在项目的属性(在 C / C ++ - >常规 - >其他包含目录)或
  • 中列出
  • 可以在VisualStudio中设置路径 - 将其添加到工具 - >选项 - >项目和解决方案 - > VC ++目录
  • $ b
  • FileWrite.h should either be in the same directory as your source code file (.cpp) or
  • Path to that header file should should be listed in project's Properties (in C/C++ -> General -> Additional Include Directories) or
  • Path could be set in your VisualStudio - add it to Include Files in Tools->Options->Projects and Solutions->VC++ Directories

这些选项shell中的哪一个取决于该标头是来自此项目(第一选项)还是其他项目(任何其他两个选项)。

Which of these options shell be used depends on whether that header originates from this project (1st option) or some other project (any of other two options).

这篇关于如何在Visual Studio 2008中包括头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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