首页 > 解决方案 > 如何在 VSCode 中使用 C++ 的 Boost?

问题描述

我正在学习 C++,我想尝试包含库,所以我从 Boost 开始,但我没有成功运行它。我在 Visual Studio Code 上运行 C++ 和 g++,使用C/C++ for VSCode由 Microsoft 编译并运行C/C++ 编译和运行 https://marketplace.visualstudio.com/items?itemName=danielpinto8zz6.c-cpp -编译-运行。这是我的代码和我的设置:

#include <boost/log/trivial.hpp>

int main()
{
    BOOST_LOG_TRIVIAL(trace) << "A trace severity message !";
}

终端中的错误:

"C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin\g++.exe" -g C:\Users\balth\Documents\Programmation\C++\testincludes.cpp -o C:\boost\include\boost-1_70\ C:\boost\lib C:\Users\balth\Documents\Programmation\C++\testincludes.exe

c_cpp_properties.json文件

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\boost\\include\\boost-1_70\\",
                "C:\\boost\\lib\\"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "${default}",
            "compilerArgs": [],
            "browse": {
                "path": [
                ]
            }
        }
    ],
    "version": 4
}

task.json文件:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe générer le fichier actif",
            "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "C:\\boost\\include\\boost-1_70\\",
                "C:\\boost\\lib",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Tâche générée par le débogueur."
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe générer le fichier actif",
            "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "C:\\boost\\include\\boost-1_70\\",
                "C:\\boost\\lib",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compilateur : \"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe\""
        },
        {
            "type": "cppbuild",
            "label": "C/C++: cpp.exe générer le fichier actif",
            "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\cpp.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "C:\\boost\\include\\boost-1_70\\",
                "C:\\boost\\lib",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compilateur : \"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\cpp.exe\""
        },
        {
            "type": "cppbuild",
            "label": "C/C++: cpp.exe générer le fichier actif",
            "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\cpp.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "C:\\boost\\include\\boost-1_70\\",
                "C:\\boost\\lib",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compilateur : \"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\cpp.exe\""
        }
    ],
    "version": "2.0.0"
}   

标签: c++

解决方案


推荐阅读