Ubuntu 18.0/20.0 vscode 配置 C环境
文件夹配置参考:
https://code.visualstudio.com/docs/editor/variables-reference
${workspaceFolder} - VS Code 中打开的文件夹目录 (通常是项目的位置)
${workspaceFolderBasename} - 没有任何斜杠 (/)的 VS Code 中打开的文件夹目录
${file} - 目前打开文件的绝对位置
${relativeFile} - 目前打开文件相对于 workspaceFolder 的相对位置
${fileBasename} - 目前打开文件的文件名(有拓展名,如: main.cpp)
${fileBasenameNoExtension} - 目前打开文件的出去拓展名的文件名(无拓展名, 如: main.cpp)
${cwd} - task runner的工作目录
${fileDirname} - 目前打开文件的目录位置
${fileExtname} - 目前打开文件的拓展名
${lineNumber} - 文件中目前被选择的行数
${selectedText} - 文件中目前被选择的内容
sudo apt-get update
sudo apt install gcc
sudo apt install gdb
sudo apt install clang
sudo apt install lldb
c_cpp_properties.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | { "configurations" : [ { "name" : "linux-gcc-x64" , "includePath" : [ "${workspaceFolder}/**" ], "compilerPath" : "/usr/bin/gcc" , "cStandard" : "${default}" , "cppStandard" : "${default}" , "intelliSenseMode" : "linux-gcc-x64" , "compilerArgs" : [ "" ] } ], "version" : 4 } |
launch.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | { "version" : "0.2.0" , "configurations" : [ { "name" : "(gdb) Launch" , "type" : "cppdbg" , "request" : "launch" , "program" : "${workspaceFolder}/${fileBasenameNoExtension}.out" , "args" : [], "stopAtEntry" : false , "cwd" : "${workspaceFolder}" , "environment" : [], "externalConsole" : true , "MIMode" : "gdb" , "preLaunchTask" : "build" , "miDebuggerArgs" : "-q -ex quit; wait() { fg >/dev/null; }; /usr/bin/gdb -q --interpreter=mi" , "setupCommands" : [ { "description" : "Enable pretty-printing for gdb" , "text" : "-enable-pretty-printing" , "ignoreFailures" : true } ] }, { "name" : "C/C++ Runner: Debug Session" , "type" : "cppdbg" , "request" : "launch" , "args" : [], "stopAtEntry" : false , "externalConsole" : false , "cwd" : "/home/geovindu/桌面/ctest" , "program" : "/home/geovindu/桌面/ctest/build/Debug/outDebug" , "MIMode" : "gdb" , "miDebuggerPath" : "gdb" , "setupCommands" : [ { "description" : "Enable pretty-printing for gdb" , "text" : "-enable-pretty-printing" , "ignoreFailures" : true } ] } ] } |
settings.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | { "C_Cpp_Runner.cCompilerPath" : "gcc" , "C_Cpp_Runner.cppCompilerPath" : "g++" , "C_Cpp_Runner.debuggerPath" : "gdb" , "C_Cpp_Runner.cStandard" : "c11" , "C_Cpp_Runner.cppStandard" : "c++11" , "C_Cpp_Runner.msvcBatchPath" : "" , "C_Cpp_Runner.useMsvc" : false , "C_Cpp_Runner.warnings" : [ "-Wall" , "-Wextra" , "-Wpedantic" , "-Wshadow" , "-Wformat=2" , "-Wcast-align" , "-Wconversion" , "-Wsign-conversion" , "-Wnull-dereference" ], "C_Cpp_Runner.msvcWarnings" : [ "/W4" , "/permissive-" , "/w14242" , "/w14287" , "/w14296" , "/w14311" , "/w14826" , "/w44062" , "/w44242" , "/w14905" , "/w14906" , "/w14263" , "/w44265" , "/w14928" ], "C_Cpp_Runner.enableWarnings" : true , "C_Cpp_Runner.warningsAsError" : false , "C_Cpp_Runner.compilerArgs" : [], "C_Cpp_Runner.linkerArgs" : [], "C_Cpp_Runner.includePaths" : [], "C_Cpp_Runner.includeSearch" : [ "*" , "**/*" ], "C_Cpp_Runner.excludeSearch" : [ "**/build" , "**/build/**" , "**/.*" , "**/.*/**" , "**/.vscode" , "**/.vscode/**" ], "C_Cpp_Runner.useAddressSanitizer" : false , "C_Cpp_Runner.useUndefinedSanitizer" : false , "C_Cpp_Runner.useLeakSanitizer" : false , "C_Cpp_Runner.showCompilationTime" : false , "C_Cpp_Runner.useLinkTimeOptimization" : false } |
tasks.json (C)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | { // 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" : "gcc" , //C++ using g++ "args" : [ "-g" , "${file}" , "-std=c11" , "-o" , "${fileBasenameNoExtension}.out" ] } ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | { "tasks" : [ { "type" : "cppbuild" , "label" : "C/C++: gcc.exe 生成活动文件" , //和preLaunchTask一致 "command" : "gcc" , //让g++执行 的.c文件变为.exe文件 用可以用: C:\\GC\\mingw64\\bin\\gcc.exe "args" : [ "-fdiagnostics-color=always" , "-g" , //调试的选项 //"${file}", //当执行哪一个文件,编译器就解释那个文件。 "${workspaceFolder}/*.c" , //*.c 需要当前指定的文件至.c的文件编译所有.c的文件 ${workspaceFolder}/*.c 在当前选择其他JSON文件时,它也会编译 https://stackoverflow.com/questions/71924077/configuring-task-json-and-launch-json-for-c-in-vs-code "-std=c11" , "-finput-charset=UTF-8" , "-fexec-charset=GBK" , //解决输出中文问题 "-o" , "${fileDirname}\\${fileBasenameNoExtension}.exe" //生成exe文件 ], "options" : { "cwd" : "${fileDirname}" }, "problemMatcher" : [ "$gcc" ], "group" : { "kind" : "build" , "isDefault" : true }, "detail" : "调试器生成的任务。" } ], "version" : "2.0.0" } |
tasks.json (C++)
1 2 3 4 5 6 7 8 9 10 11 12 13 | { // 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++" , //g++ c++ c++11 gcc c11 "args" : [ "-g" , "${file}" , "-std=c++11" , "-o" , "${fileBasenameNoExtension}.out" ] } ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | { // 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" : "gcc" , //g++ c++ c++11 gcc c11 "args" : [ "-g" , //"${file}", "*.c" , "-std=c11" , "-o" , "${fileBasenameNoExtension}.out" ] } ] } |
https://code.visualstudio.com/docs/cpp/customize-default-settings-cpp
https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
C_Cpp.default.cStandard : c89 | c99 | c11 | c17
C_Cpp.default.cppStandard : c++98 | c++03 | c++11 | c++14 | c++17 | c++20 | c++23
sudo apt-get update
sudo apt install openssh-server
sudo apt-get install vim
vim /etc/ssh/sshd_config
PermitRootLogin yes
sudo /etc/init.d/ssh restart
sudo ps -e | grep ssh
sudo apt-get install net-tools
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
2022-09-17 Csharp: Abstract Factory Pattern
2022-09-17 Csharp:Factory Method Pattern
2022-09-17 Csharp: Simple Factory Pattern
2022-09-17 java: Decorator Pattern
2022-09-17 java: Composite Pattern
2022-09-17 java: Adapter Pattern
2012-09-17 SQL 生成公曆和農曆對照數據,公曆查找農曆和農曆查找公曆函數