赞
踩
*\mingw64\bin*
添加到环境变量即可C/C++
code runner
, 修改配置File>Preferences>setting>User>Run Code configuration#include <iostream>
using namespace std;
int main(){
cout<< "Hello World!"<<endl;
return 0;
}
运行
ctrl+alt+n
orF5
F5
运行创建了.vscode/launch.json
{ "version": "0.2.0", "configurations": [ { "name": "C/C++", //配置名称 "type": "cppdbg", //配置类型,默认 "request": "launch", //请求配置类型,launch启动,attach附加? "program": "${fileDirname}/${fileBasenameNoExtension}.exe", //调试程序路径 "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", //工作目录 "environment": [], "externalConsole": true, //是否显示控制台 "MIMode": "gdb", "miDebuggerPath": "C:/Program Files/mingw64/bin/gdb.exe", //gdb路径 "preLaunchTask": "g++", //编译g++/c++,gcc/c "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], }, ] }
F5
弹框,点击configure task, 编辑tasks.json
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "type": "shell", "label": "cpp.exe build active file", //"command": "D:\\mingw64\\bin\\cpp.exe", "command": "g++", "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "D:\\mingw64\\bin" }, "problemMatcher": [ "$gcc" ], "group": "build" } ] }
基本参照这个配置,建议看原文,只有tasks.json
中"label": "cpp.exe build active file",
这样必须有,其他均一致
-2019.11.19更新,在新的电脑上这样配置task.json
, 不行,参考这个,修改
"label": "g++", //和launch.json中preLaunchTask一致
"command": "D:/mingw64/bin/g++.exe",
ctrl+alt+n
可以运行F5
并不会出现.json
配置Terminal-->Configure Tasks
,会自动帮你生成.vscode
目录.vscode
文件夹下新建launch.json
tasks.json
launch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/${fileBasenameNoExtension}.out", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "preLaunchTask":"build", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": ["-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]
}
]
}
F5
运行OK
#include<caffe/caffe.hpp>
出错,参考这个
ctrl+shift+p
选择c/c++ config
,会创建c_cpp_properties.json
文件{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "/home/wl/software/caffe/include" ], "browse": { "path": [ "${workspaceFolder}", "/home/wl/software/caffe/include" ], "limitSymbolsToIncludedHeaders": true, "databaseFilename": "" }, "defines": [], "compilerPath": "/usr/bin/gcc", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "clang-x64" } ], "version": 4 }
实验证明,"browse"这个参数可以不配置
task.json
"args": ["-g", "${file}", "-I", "/home/wl/software/caffe/include", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]
-I
表示包含头文件路径,实验证明不要这个配置也行
"message": "cannot open source file \"cublas_v2.h\" (dependency of \"caffe/caffe.hpp\")",
经查阅,是caffe有关cuda配置的,但是我的caffe明明编译的是cpu版本…
#include<caffe/caffe.hpp>
出错问题,重开一个记录vscode 运行python 脚本时,不能在终端使用conda activate env_name 激活环境
按照 https://github.com/Microsoft/vscode-python/issues/5541 在终端运行 conda init powershell
, 重启终端即可。
没有配置科学上网,连接远程服务器总是出现由于vscode-server.tat.gz
而连不上
原始的下载网址为
https://update.code.visualstudio.com/commit:3b889b090b5ad5793f524b5d1d39fda662b96a2a/server-linux-x64/stable
commit
后面的一串就是你的vscode commit id 替换即可,但是上述网址打不开
一个可替代的网址是
https://vscode.cdn.azure.cn/stable/3b889b090b5ad5793f524b5d1d39fda662b96a2a/vscode-server-linux-x64.tar.gz
/root/.vscode-server/bin
文件夹下创建commit id
的文件夹vscode-server.tar.gz
移动到此文件夹下tar -xvf vscode-server.tar.gz
commit id
文件夹下即可mv vscode-server/* .
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。