首页 > 解决方案 > 尝试在 MS Visual Studio 代码中安装 boost 1_70 C++ 但得到“不存在此类文件”

问题描述

我正在遵循这个程序。我正在使用带有代码运行器扩展的 minGW 编译器的 MS Visual Studio 代码。我想我已经成功构建了 b2 引擎。这是输出

boost-install.generate-cmake-config-version- C:\Program Files\boost\lib\cmake\boost_math_tr1l-1.70.0\boost_math_tr1l-config-version.cmake boost-install.generate-cmake-variant- C:\Program Files\boost\lib\cmake\boost_math_tr1l-1.70.0\libboost_math_tr1l-variant-mgw92-mt-d-x32-1_70-static.cmake boost-install.generate-cmake-config- 
C:\Program Files\boost\lib\cmake\boost_math-1.70.0\boost_math-config.cmake boost-install.generate-cmake-config-version- 
C:\Program Files\boost\lib\cmake\boost_math-1.70.0\boost_math-config-version.cmake ...
failed updating 678 targets... ...skipped 278 targets... ...updated 16845 targets...

任务.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cpp.exe build active file",
            "command": "C:\\MinGW\\bin\\cpp.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "-L",
                "-1",
                "-IC:\\Program Files\\boost\\include\\boost-1_70",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\MinGW\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

和 c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\Program Files\\boost\\include\\boost-1_70"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x86"
        }
    ],
    "version": 4
}

以下是我尝试运行的代码:

#include <bits/stdc++.h>
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " ");
}

但得到以下错误:

    PS C:\Users\dwiti\OneDrive\Documents\My Bluetooth> cd "c:\Users\dwiti\OneDrive\Documents\My Bluetooth\" ; if ($?) { g++ worthless.cpp -o worthless } ; if ($?) { .\worthless }        
worthless.cpp:2:10: fatal error: boost/lambda/lambda.hpp: No such file or directory
    2 | #include <boost/lambda/lambda.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

注意-我正在使用 MinGW g++ 编译器,并且也成功添加了受人尊敬的环境路径。而且我已经尝试了所有以前的答案解决方案,但由于某些我不明白的原因,它们对我不起作用。请帮我解决这个问题。谢谢!。

标签: c++windowsvisual-studio-codeboostmingw

解决方案


推荐阅读