我想在 Visual Studio Code 中包含并使用 boost 库 (https://www.boost.org/)。这是我的测试.cpp:
在 VS Code 中运行代码后出现错误,右上角有箭头:
我还添加了我的 .json 文件:
我不知道将 boost-folder 包含在 .json 文件中是否足够。包含 .hpp 文件的文件夹位于“boost_1_80_0”的子目录中。
有人可以帮助我吗?
提前谢谢您
雅各布
我今天遇到了同样的问题,并按照 HolyBlackCat 的建议,通过将
-I path/to/include/dir
编译器标志添加到项目文件夹中 tasks.json
文件夹中的 .vscode
文件来修复它。
棘手的部分是,"-I"
和"C:/Program Files/Boost/boost_1_84_0/"
是flags
部分下的单独项目,如下所示:
"args": [
"/Zi",
"/EHsc",
"/nologo",
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}",
"-I",
"C:/Program Files/Boost/boost_1_84_0/",
]
供参考,整个
task.json
看起来像这样:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/nologo",
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}",
"-I",
"C:/Program Files/Boost/boost_1_84_0/",
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}