简体   繁体   English

Visual Studio 2012错误:无法打开源文件

[英]Visual Studio 2012 Error: Cannot open source file

I have source code (header and source files)of a library. 我有一个库的源代码(头文件和源文件)。 I need to include the source code in my existing project. 我需要在现有项目中包含源代码。 For that purpose i have copied the entire library source code directory into visual studio project folder then i included that directory to VS by using include to project option. 为此,我已将整个库源代码目录复制到Visual Studio项目文件夹中,然后通过使用include to project选项将该目录包含到VS中。 Fine. 精细。

There is a header file say "xh" in the library source code directory which defines some macros, and there are some other header files say "yh" and "zh" which are using those macros defined in "xh". 库源代码目录中有一个头文件“ xh”,它定义了一些宏,还有其他头文件“ yh”和“ zh”,它们使用了在“ xh”中定义的那些宏。 But visual studio is not recognising those macros at all when i included those ("yh" and "zh") header files in my main class. 但是,当我在主类中包含这些头文件(“ yh”和“ zh”)时,Visual Studio根本无法识别这些宏。 Visual Studio generates the error "Cannot open this source file". Visual Studio生成错误“无法打开此源文件”。

Actually "yh" and "zh" can not find macros defined in "xh". 实际上,“ yh”和“ zh”找不到在“ xh”中定义的宏。 How to solve this error? 如何解决这个错误? Is there some kind of setting need in the project properties? 项目属性中是否需要某种设置?

My second question is that how to include some programming files in my project correctly so that i can use that library functionality correctly? 我的第二个问题是,如何在项目中正确包含一些编程文件,以便我可以正确使用该库功能? I have also Include the header directories in configuration properties > VC++ Diectories > Include Directories. 我还在配置属性> VC ++部门>包含目录中包含头目录。

Third question is that is there a way in which i don't have to include the source code to my project? 第三个问题是,有没有一种方法不必将源代码包含到我的项目中? remember i don't have .lib file or .dll file of that library and i cannot compile that library also. 请记住,我没有该库的.lib文件或.dll文件,并且我也无法编译该库。

Have you add 你有加吗

#include <x.h>

or 要么

#include "x.h"

Are library files in a sub-folder? 库文件是否在子文件夹中? if Yes try 如果可以,请尝试

#include ".\subfoldername\x.h"

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

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