visual studio 2010包括目录路径 [英] visual studio 2010 include directory paths

查看:193
本文介绍了visual studio 2010包括目录路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个visual studio解决方案myvs.sln,其路径如下: c:\dir1 \dir2 \dir3 \ myvs \ myvs \ myvs.sln 。我在 c:\dir1 \dir2 \dir3 \ boostxxx \ 中安装了升级版xxx。

I have a visual studio solution myvs.sln with the following path: c:\dir1\dir2\dir3\myvs\myvs\myvs.sln. I have boost version xxx installed in c:\dir1\dir2\dir3\boostxxx\.

我在项目中 - > properties-> c / c ++ - > general: ../..;../../ boostxxx 。在boost文件库中,包含文件具有以下语法: #include< boost / smart_ptr / shared_ptr>

I have in the project->properties->c/c++->general: ../..;../../boostxxx. Inside boost libraries the include files have the following syntax: #include <boost/smart_ptr/shared_ptr>.

我的代码文件 myfile.h 位于 c:\dir1 \dir2 \dir3\yy1\myfile.h 。在myfile.h中,我将boost库包含在: #include< boost / shared_ptr.hpp> 。我收到一条错误,上面写着: c:\dir1 \dir2 \dir3 \yyy1 / myfile.h致命错误C1083无法打开包含文件boost / shared_ptr.hpp

My code file myfile.h resides in c:\dir1\dir2\dir3\yy1\myfile.h. In myfile.h I include boost libraries as: #include <boost/shared_ptr.hpp>. I am getting a error which says: c:\dir1\dir2\dir3\yyy1/myfile.h fatal error C1083 cannot open include file boost/shared_ptr.hpp.

问题是我应该怎么做才能纠正这个问题?

The question is what should I do to correct this?

我还注意到错误输出了编译器投掷有\到dir3然后更改为/\".

I also notice that the error output the compiler throws has "\" upto dir3 and then changes to "/".

我很可能不明白相对路径是如何工作的。另请注意,我只想引用相对路径而不是绝对路径。有人可以帮忙吗?我在Windows平台上使用c ++ visual studio 2010。

Most probably I do not understand how the relative path is working. Also note that I want to refer to only relative path not absolute paths. Can someone please help? I am in windows platform using c++ visual studio 2010.

推荐答案

搜索路径中的相对路径 参考使用 #include 指令编译器的当前目录文件的目录,现在显示一些简单的测试。

Relative paths in the search paths refer to the directory of the file with the #include directive the current directory of the compiler, some simple testing now shows.

.. \ ..从你的头文件升级到编译器的当前目录而不是你的项目目录。

"..\.." is going up two levels from your header file the current directory of the compiler instead of from your project directory.

要解决此问题,请在Visual Studio项目目录中显式启动包含路径,如下所示(字面意思):

To fix this, explicitly start your include paths in your Visual Studio project directory, as follows (literally):


$(ProjectDir).. \ ..; $(ProjectDir).. \..\BoostXXX

$(ProjectDir)..\..;$(ProjectDir)..\..\BoostXXX

关于正斜杠和反斜杠,在C ++代码的 #include 指令中使用正斜杠,因为这是最便携的。

Regarding forward versus backward slash, use forward slash in your C++ code's #include directives, because that's most portable.

使用向前或向后斜杠(但我更喜欢向后斜杠以便有一个转换你指的是Windows文件系统,例如在包含路径的设置中。

Use either forward or backward slash (but I prefer backwards slash so as to have a single convention) where you're referring to the Windows file system, such as in the setup of include paths.

这篇关于visual studio 2010包括目录路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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