Quantcast
Channel: 丁才軒討論站
Viewing all articles
Browse latest Browse all 42

Windows • Visual Studio Code (VS code)設定C/C++的組態問題

$
0
0
launch.json: 一般放置於專案目錄下, 不可和不同程式語言混用同一個貝錄,以免發生載入錯亂
例如: python 檔和 C/C++ 檔需使用不同的 launch.json (或許可以同一個launch.json裡設定二種語言?)
--------------

CODE:

{    // 使用 IntelliSense 以得知可用的屬性。    // 暫留以檢視現有屬性的描述。    // 如需詳細資訊,請瀏覽: https://go.microsoft.com/fwlink/?linkid=830387    "version": "0.2.0",    "configurations": [                {            "name": "g++.exe - 建置及偵錯使用中的檔案",            "type": "cppdbg",            "request": "launch",            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",            "args": [],            "stopAtEntry": false,            "cwd": "C:\\MinGW\\bin",            "environment": [],            "externalConsole": false,            "MIMode": "gdb",            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",            "setupCommands": [                {                    "description": "啟用 gdb 的美化顯示",                    "text": "-enable-pretty-printing",                    "ignoreFailures": true                }            ],            "preLaunchTask": "C/C++: g++.exe 建置使用中檔案"        }    ]}
task.json: 用於組建程式(build task)
使用 MinGW時需將 libgcc_s_dw2-1.dll 和 libstdc++-6.dll 複製到工作目錄下,否則無法執行 .exe 檔;
或者 修改 task.json 加入 compiler flag, 即加入 -static-libgcc 和 -static-libstdc++
----------

CODE:

{"version": "2.0.0","tasks": [{"type": "cppbuild","label": "C/C++: g++.exe 建置使用中檔案","command": "C:\\MinGW\\bin\\g++.exe","args": ["-g","-static-libgcc","-static-libstdc++","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "C:\\MinGW\\bin"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "編譯器: C:\\MinGW\\bin\\g++.exe"}]}

統計資料: 發表於 由 dtchang — 2021-08-09, 12:44



Viewing all articles
Browse latest Browse all 42

Latest Images

Trending Articles





Latest Images