Rec*_*r12 5 c++ boost visual-studio-code
所以我基本上构建了整个boost库并将它们放在C:\boost\include\boost-1_73中。但我有一种感觉,在使用这个库之前我必须包含更多步骤。我一直遵循本指南,直到将其设置为 Visual Studio 代码。所以现在我正在互联网上搜索如何设置它。这是我遵循的指南。但我没有像指南中那样将其包含在program_files目录中。
https://gist.github.com/sim642/29caef3cc8afaa273ce6
在我的 Task.Json 中我有
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "C:\\new\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\g++.exe",
"args": [
"-g",
"${fileDirname}\\**.cpp",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
在我的主要 settings.json 中我有
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"code-runner.saveFileBeforeRun": true,
"code-runner.saveAllFilesBeforeRun": true,
"code-runner.fileDirectoryAsCwd": true,
"code-runner.ignoreSelection": true,
"haskelly.exec.reuseTerminal": true,
"C_Cpp.updateChannel": "Insiders",
"r.rterm.windows": "C:\\Program Files\\R\\R-3.6.1\\bin\\R",
"vsicons.dontShowNewVersionMessage": true,
"files.autoSave": "onWindowChange",
"workbench.colorCustomizations": {},
"editor.tokenColorCustomizations": null,
"php.validate.executablePath": "",
"code-runner.executorMap": {
"cpp": "cd $dir && g++ *.cpp -o $fileNameWithoutExt -I C:/boost/include/boost-1_73 -L C:/boost/lib && $fileNameWithoutExt.exe"
},
"code-runner.executorMapByFileExtension": {},
"cmake.configureOnOpen": true,
"explorer.confirmDelete": false,
"editor.formatOnSave": true,
"workbench.statusBar.visible": true,
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "Better Solarized Light",
"code-runner.clearPreviousOutput": true,
"code-runner.runInTerminal": true,
"C_Cpp.loggingLevel": "Debug",
"explorer.sortOrder": "type",
"C_Cpp.default.forcedInclude": [],
"C_Cpp.default.includePath": [
"C:\\boost\\include\\boost-1_73",
],
}
Run Code Online (Sandbox Code Playgroud)
我将如何包含链接器(我什至要包含链接器吗?)或者如果我做得正确的话?我需要在任务中包含 boost 的路径吗?在我看来,我唯一做的就是将它包含在智能感知中,而我现在对如何使用它有点迷失了。我将非常感谢您的帮助。
编辑我通过修改以下代码进行了更改,并创建了一个 CPP 文件来测试 lambda 头文件
#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) << " ");
}
Run Code Online (Sandbox Code Playgroud)
显然该文件不存在:
fatal error: boost/lambda/lambda.hpp: No such file or directory
#include <boost/lambda/lambda.hpp>
Run Code Online (Sandbox Code Playgroud)
请注意,我正在使用 Visual Studio Code 运行程序扩展运行所有内容。
Boost 的某些部分仅包含标头,某些部分则应链接。
您应该为编译器(添加-I到args中tasks.jsons)和 IntelliSense(在 中settings.json)指定 Boost 包含目录。如果您不使用 Boost 中非标头部分,那么这基本上就是您所需要的。否则,您必须添加-l和-L选项来tasks.json指定要链接的 Boost 库以及在哪里可以找到它们。
如果g++由某个扩展运行,您也应该在那里添加-I,-L和-l选项。
| 归档时间: |
|
| 查看次数: |
13765 次 |
| 最近记录: |