简体   繁体   English

Visual Studio C++ 不能在同一解决方案或外部文件夹中包含其他目录

[英]Visual Studio C++ Can't include additional directory within same solution or outside folder

So I'm learning C++ this semester and right on the first laboratory I got a problem which nor me, nor my prof could solve.所以我这个学期正在学习 C++,就在第一个实验室里,我遇到了一个我和我的教授都无法解决的问题。 Our task was really basic.我们的任务非常基本。 Create a solution, create a project in which create a function and a header file.创建一个解决方案,创建一个项目,在该项目中创建一个 function 和一个 header 文件。 In the header file is the declaration of the function. header文件中是function的声明。 Then create a new project (in same solution), add the old one as a reference.然后创建一个新项目(在同一解决方案中),添加旧项目作为参考。 Now comes the part which gave me a headache.现在到了让我头疼的部分。 Add the path of the folder of the.h file into the " Additional Include Directories " section.将 .h 文件的文件夹路径添加到“附加包含目录”部分。 Well I do that and nothing.好吧,我这样做了,什么也没有。 I tried diferent locations, but nothing worked.我尝试了不同的位置,但没有任何效果。 Any idea how can I solve this problem?知道如何解决这个问题吗?

Here are some pictures:以下是一些图片:

The "code".编码”。 It is not much不多

The path路径

Even if the directory is listed, you still have to reference header with #include "yourHeader.h" wherever you want to use the forward-declared functions.即使列出了目录,您仍然必须在要使用前向声明的函数的任何地方使用#include "yourHeader.h"引用 header。

I suggest that you could first manually find the directory where the.h file is located, and then add the path in VS.我建议你可以先手动找到.h文件所在的目录,然后在VS中添加路径。

在此处输入图像描述

If it doesn't work, I suggest that you could add the path in Properties->VC++ Directories->Include Directories .如果它不起作用,我建议您可以在Properties->VC++ Directories->Include Directories中添加路径。

Also, you could refer to Microsoft Docs for more information.此外,您可以参考Microsoft Docs了解更多信息。

I reinstalled VisualStudio and now it works prefctly.我重新安装了 VisualStudio,现在它可以正常工作了。 FML FML

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

相关问题 Visual Studio 中用于 C++ 的其他包含目录 - Additional include directories in Visual Studio for C++ Visual Studio 2015中的其他包含目录不起作用 - Additional include directory in Visual studio 2015 doesn't work 不能包含 cliext 标头(对于 c++ cli、Visual Studio) - Can't include cliext headers (for c++ cli, Visual Studio) Visual Studio 无法显示 C++ 文件的文件夹 - Visual Studio can't show folder of C++ files 如何在Microsoft Visual Studio 2013的同一解决方案中执行不同的C ++文件? - How do you execute different C++ files within the same solution in microsoft visual studio 2013? Visual C++:#include 来自同一解决方案中其他项目的文件 - visual c++: #include files from other projects in the same solution Visual Studio 2010:C/C++ 全局包含和 lib 文件夹 - Visual Studio 2010: C/C++ global include and lib folder 如何在 Visual Studio c++ 的解决方案目录中打开文件? - How to open a file in solution directory in Visual Studio c++? 将一批库和目录路径包含到“包含附加目录”Visual C++ 的任何方式 - Any way to include a batch of Library and Directory paths to "Include Additional Directories" Visual C++ Visual Studio 2015 C ++解决方案无法在系统PATH中看到svn exe - Visual Studio 2015 C++ solution can't see svn exe in system PATH
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM