0
点赞
收藏
分享

微信扫一扫

3DE DELMIA Role: PSFEM - Structure Fabrication Engineer for Marine

全栈顾问 2024-04-26 阅读 9

一、开发环境搭建

·安装mingw-w64编译器(GCC for Windows 64 & 32 bits)、Cmake工具(选装)

·VSCode插件安装

        ·C/C++

        ·cmake

        ·cmake tools

二、代码实践演练

·基于g++命令

        ·g++编译文件,生成带调试信息的可执行文件、并调试

        ·g++编译多文件,生成带调试信息的可执行文件、并调试

默认的tasks.json是编译单个文件的,不会去自动识别多个文件,我们必须手动去配置launch.json和tasks.json这两个文件。

·基于cmake

        ·编写最简单的CMakeLists.txt

        ·进行多文件编译,并调试

·配置json

        ·launch.json --- for debug

{
"configurations": [
{
"name": "C/C++: g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/build/my_cmake_swap.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "E:\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "Build"
}
],
"version": "2.0.0"
}

        ·tasks.json --- for build before debug

{   
"version": "2.0.0",
"options": {
"cwd": "${fileDirname}/build"
},
"tasks": [
{
"type": "shell",
"label": "cmake",
"command": "cmake",
"presentation": {
"panel": "new"
},
"args": [
".."
],
},
{
"label": "make",
"group": {
"kind": "build",
"isDefault": true
},
"command": "mingw32-make.exe",
"args": [

],
},
{
"label": "Build",
"dependsOn":[
"cmake",
"make"
]
},
],
}

如若遇到以下问题:

在setting.json中加入上述框框中的代码即可。

{
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"files.autoSave": "onFocusChange",
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "Material Theme Ocean",
"workbench.editorAssociations": {
"*.exe": "default"
},
"cmake.configureOnOpen": true,
"cmake.options.advanced": {
"build": {
"statusBarVisibility": "inherit",
"inheritDefault": "visible"
},
"launch": {
"statusBarVisibility": "inherit",
"inheritDefault": "visible"
},
"debug": {
"statusBarVisibility": "inherit",
"inheritDefault": "visible"
}
},
"cmake.options.statusBarVisibility": "visible",
"cmake.showOptionsMovedNotification": false
}
举报

相关推荐

0 条评论