开发者

Why can't I include this .h?

I have the following directory structure:

Why can't I include this .h?

I wrote the includes:

#include "obj.开发者_开发知识库h"
#include "textura.h"

Yet, I'm getting:

fatal error C1083: Cannot open include file: 'obj.h': No such file or directory.

Why?

I tried previously to move the files to "header files", it didn't work, same error.


Take a look at the directory path of obj.h (should be in file properties) and make sure that the directory that it's in is present in your project's default include directories.


"Directory structure" that is shown does not actually exist. It is neither directory nor structure. Folders inside solution explorer are used only to visually group files, and for nothing more. The real question is where is obj.h located on disk. It must be in the same folder where .cpp is, which you want to compile. If it is not on the same folder then you:

  • move obj.h in the same folder where .cpp is, or
  • change #include directive to be a relative path beginning from .cpp and ending to obj.h, or
  • set option in project that tells compiler where to find obj.h (Properties > C/C++ > General > Additional Include Directories), or
  • set option in Visual Studio that tells compiler where to find obj.h. This option is used for MSDN, or some other framework that you rely on heavily, and it should not be used for your own files.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜