'cannot open source file "boost/algorithm/hex.hpp"

Got an error on VS Code while trying to include the library boost/algorithm/hex.hpp. The error said "#include errors detected. Please update your includePath". I updated the path, but didn't work.

Maybe the path I adding isn't the correct one?

Path image

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\Program Files (x86)\boost_1_78_0\boost_1_78_0\boost\\algorithm"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}


Solution 1:[1]

The include path should be set to the base directory of the Boost installation -- in your case, C:\\Program Files (x86)\boost_1_78_0\boost_1_78_0\.

The include statement -- #include "boost/algorithm/hex.hpp" -- already includes the relevant subdirectories.

(This is as should be. Do not shorten the #include -- you would a) lose contextual information, i.e. which library the #include is from; b) possibly run into file name collisions; c) need to extend the include path for each sublibrary of Boost you are using.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DevSolar