為什么80%的碼農都做不了架構師?>>> ??
裝cygwin 或者mingGW,裝gcc工具鏈,并將cygwin的bin目錄加入環境變量PATH中。
ctrl+shift+b
{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "gcc","command": "g++","args": ["-g ${file}", //指定編譯源代碼文件 "-o ${fileDirname}/${fileBasenameNoExtension}.exe", // 指定輸出文件名,不加該參數則默認輸出a.exe"-ggdb3", // 生成和調試有關的信息"-Wall", // 開啟額外警告"-static-libgcc", // 靜態鏈接"-std=c++17", // 使用最新的c++17標準"-Wno-format","-finput-charset=UTF-8",//輸入編譯器文本編碼 默認為UTF-8"-fexec-charset=GBK"//編譯器輸出文本編碼 自行選擇],"type": "shell","group": {"kind": "build","isDefault": true},"presentation": {"echo": true,"reveal": "always", // 在“終端”中顯示編譯信息的策略,可以為always,silent,never"focus": false,"panel": "shared" // 不同的文件的編譯信息共享一個終端面板},"problemMatcher": {"owner": "cpp","fileLocation": ["relative", "\\"],"pattern": {"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$","file": 1,"line": 2,"column": 3,"severity": 4,"message": 5}}}]
}
launch.json
{// 使用 IntelliSense 了解相關屬性。 // 懸停以查看現有屬性的描述。// 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "(gdb) Launch","type": "cppdbg","request": "launch",//"program": "${file}.exe","program": "${fileDirname}/${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,//"cwd": "${workspaceFolder}","cwd": "${fileDirname}","environment": [],"externalConsole": true,"MIMode": "gdb","miDebuggerPath": "gdb.exe","preLaunchTask": "gcc","windows": {"setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}}]
}
?
cuckoo的配置如下,其中參數是從makefile里面提取出來的。
{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "echo","type": "shell","command": "i686-w64-mingw32-gcc","args": ["-m32 -Wall -Wextra -std=c99 -static -Wno-missing-field-initializers -I inc/ -I objects/code/ -I src/bson/ -I src/sha1/", //-mwindows//最后一個參數 -mwindows加上后輸出只能出現在cygwin環境,而不會出現在dos環境"-g","${file}","-o","${workspaceRoot}/test.exe"],"group": {"kind": "build","isDefault": true}}]
}
?
完整版配置環境:
task.json
{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "mingw32","command": "i686-w64-mingw32-gcc","args": ["-m32 -Wall -Wextra -std=c99 -static -Wno-missing-field-initializers -I inc/ -I objects/code/ -I src/bson/ -I src/sha1/","-g ${file}", //指定編譯源代碼文件 "-o ${fileDirname}/${fileBasenameNoExtension}.exe", // 指定輸出文件名,不加該參數則默認輸出a.exe"-ggdb3", // 生成和調試有關的信息"-Wall", // 開啟額外警告"-static-libgcc", // 靜態鏈接// "-std=c++17", // 使用最新的c++17標準"-Wno-format","-finput-charset=UTF-8",//輸入編譯器文本編碼 默認為UTF-8"-fexec-charset=GBK"//編譯器輸出文本編碼 自行選擇],"type": "shell","group": {"kind": "build","isDefault": true},"presentation": {"echo": true,"reveal": "always", // 在“終端”中顯示編譯信息的策略,可以為always,silent,never"focus": false,"panel": "shared" // 不同的文件的編譯信息共享一個終端面板},"problemMatcher": {"owner": "cpp","fileLocation": ["relative", "\\"],"pattern": {"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$","file": 1,"line": 2,"column": 3,"severity": 4,"message": 5}}},{"label": "gcc","command": "g++","args": ["-g ${file}", //指定編譯源代碼文件 "-o ${fileDirname}/${fileBasenameNoExtension}.exe", // 指定輸出文件名,不加該參數則默認輸出a.exe"-ggdb3", // 生成和調試有關的信息"-Wall", // 開啟額外警告"-static-libgcc", // 靜態鏈接"-std=c++17", // 使用最新的c++17標準"-Wno-format","-finput-charset=UTF-8",//輸入編譯器文本編碼 默認為UTF-8"-fexec-charset=GBK"//編譯器輸出文本編碼 自行選擇],"type": "shell","group": {"kind": "build","isDefault": true},"presentation": {"echo": true,"reveal": "always", // 在“終端”中顯示編譯信息的策略,可以為always,silent,never"focus": false,"panel": "shared" // 不同的文件的編譯信息共享一個終端面板},"problemMatcher": {"owner": "cpp","fileLocation": ["relative", "\\"],"pattern": {"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$","file": 1,"line": 2,"column": 3,"severity": 4,"message": 5}}}]
}
launch.json
{// 使用 IntelliSense 了解相關屬性。 // 懸停以查看現有屬性的描述。// 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "mingw32","type": "cppdbg","request": "launch",//"program": "${file}.exe","program": "${fileDirname}/${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,//"cwd": "${workspaceFolder}","cwd": "${fileDirname}","environment": [],"externalConsole": true,"MIMode": "gdb","miDebuggerPath": "gdb.exe","preLaunchTask": "mingw32","windows": {"setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}},{"name": "(gdb) Launch","type": "cppdbg","request": "launch",//"program": "${file}.exe","program": "${fileDirname}/${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,//"cwd": "${workspaceFolder}","cwd": "${fileDirname}","environment": [],"externalConsole": true,"MIMode": "gdb","miDebuggerPath": "gdb.exe","preLaunchTask": "gcc","windows": {"setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}}]
}
?
?
?
參考:
VSCode下C++環境的配置
http://blog.csdn.net/feynman1999/article/details/79437524