Visual Studio 2010 includes directory paths

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

I have in the project-> properties-> c / C ++ β†’ general: ../..;../../boostxxx . Within extended libraries, the included files have the following syntax: #include <boost/smart_ptr/shared_ptr> .

My code file myfile.h is located in c:\dir1\dir2\dir3\yy1\myfile.h . In myfile.h, I include boost libraries as: #include <boost/shared_ptr.hpp> . I get an error: 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 fix this?

I also notice that the error output generated by the compiler has "\" before dir3, and then changes to "/".

Most likely, I do not understand how the relative path works. Also note that I want to refer only to a relative path, not absolute paths. Can someone help? I am on a Windows platform using visual studio 2010 C ++.

+4
source share
1 answer

Relative paths in the search path relate to #include directive file directory current compiler directory, simple testing is now shown.

".. \ .." rises two levels from your header file current compiler directory, not from your project directory.

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

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

As for backslashes or backslashes, use a slash in C ++ code #include directives because it is the most portable.

Use either a forward slash or a backslash (but I prefer the backslash to have one convention), where you refer to the Windows file system, for example, in setting up the included paths.

+3
source

Source: https://habr.com/ru/post/1445856/


All Articles