环境要求:
-
mysql5.6
-
gcc 5.2
一、下载安装Visual Studio Code工具
下载地址:https://www.296o.com/1805.html
安装步骤:
-
全部默认安装,安装好后,根据压缩包里的“VsCode汉化.txt”进行汉化,变成中文版;
-
将压缩包里的mingw64文件夹复制到D盘中;
二、导入项目
1、打开Visual Studio Code → 顶部菜单“文件” → 将文件夹添加到工作区...,然后找到阿拉德服务端源代码的目录,导入后如下图:
2、在.vscode目录下,添加下面3个配置文件(已经存在的,则修改里面的代码):
c_cpp_properties.json
{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], //注意!!!修改我 "compilerPath": "D:\\mingw64\\bin\\gcc.exe", "cStandard": "gnu17", "cppStandard": "gnu++14", "intelliSenseMode": "windows-gcc-x64" } ], "version": 4 }
launch.json
{ "version": "0.2.0", "configurations": [ { "name": "C++ Launch (GDB)", "type": "cppdbg", "request": "launch", "targetArchitecture": "x86", // 要进行调试的可执行文件的路径 "program": "${workspaceRoot}/main", // 注意!!!修改我 gdb调试器路径,这里选择TDM-GCC安装目录下的gdb "miDebuggerPath":"D:\\mingw64\\bin\\gdb.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "externalConsole": true, // 调试会话前执行的任务,这里是task.json中配置好的编译任务 "preLaunchTask": "g++", // pretty-printing配置,可以直观打印出C++中的容器 "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], } ] }
tasks.json
{ "tasks": [ { "type": "cppbuild", // g++ 是编译任务的名字,当按下Ctrl+shift+B快捷键时,在终端窗口 // 会显示"正在执行任务: g++" // 当然你可以随意修改labal "label": "g++", //注意!!!修改我 "command": "D:\\mingw64\\bin\\g++.exe", "args": [ "-fdiagnostics-color=always", "-g", "${fileDirname}\\*.h", "${fileDirname}\\*.cpp", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "-leasyx" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": "build", //注意!!!修改我 "detail": "编译器: D:\\mingw64\\bin\\g++.exe" } ], "version": "2.0.0" }
三、运行调试
1、进入ald-server-code-65/src/AdminServer目录,拉到最底部找到程序启动入口文件main.cpp,并打开它
2、直接按F5运行,可以看到如下图,运行出错了,大概原因是我的电脑缺少某些重要的环境库和mysql数据库
Ps:教程暂时先到这里,有空再继续研究,方向是对的!
请登录之后再进行评论