如何在 vscode 中添加 boost 库

问题描述

我在运行我的程序时遇到以下错误: 无法打开源文件“boost/multiprecision/cpp_int.hpp”

这是我的配置:

{
    "configurations": [
        {
            "name": "Win32","includePath": [
                
            ],"defines": [
                "_DEBUG","UNICODE","_UNICODE"
            ],"compilerPath": "C:/MinGW/bin/gcc.exe","cStandard": "gnu17","cppStandard": "c++14","intelliSenseMode": "windows-gcc-x64"
        }
    ],"version": 4
}

解决方法

您可以在 settings.json 中配置 Code-Runner 并设置自定义构建命令,例如

{
    "code-runner.executorMap": {
        "c++": "cd $dir && g++ $fileName -o $fileNameWithoutExt -IBOOST_INCLUDE_PATH -LBOOST_LIBRARY_PATH -lBOOST_LIBRARY1 -lBOOST_LIBRARY2 ... && $dir$fileNameWithoutExt"
    }
}