unp[unix 网络环境编程]学习 vscode环境搭建

开坑unp[unix 网络环境编程]学习

Github

unp[unix 网络环境编程]学习 vscode环境搭建

  1. vscode 下载安装 Native Debug,f5打开调试配置,或者按照我的文件直接覆盖就行

  2. 参考.vscode的两个文件,其中launch不用修改

  3. 如果想自己每次重新编译书本的源码,不使用默认的Makefie,则需修改task.json,这里主要就是增加头文件的路径和链接库的路径,这个参数定义在unpv13e/Make.defines

  4. 这个参数其实可以随便找个Makefile 打印变量即可,我这里修改打印看了下

    dbg:
     echo${CC} ${CFLAGS} -o $@ daytimetcpcli.o ${LIBS}
     # echo gcc -I../lib -g -O2 -D_REENTRANT -Wall -o dbg daytimetcpcli.o ../libunp.a -lpthread
    
     {
         "tasks": [
             {
                 "type": "shell",
                 "label": "gcc build active file",
                 "command": "/usr/bin/gcc",
                 // echo gcc -I../lib -g -O2 -D_REENTRANT -Wall -o dbg daytimetcpcli.o ../libunp.a -lpthread
                 "args": [
                     "-ggdb3",
                     "-I",
                     "${fileDirname}/../lib",
                     "-D_REENTRANT",
                     "-Wall",
                     "${file}",
                     "-o",
                     "${fileDirname}/${fileBasenameNoExtension}",
                     "${fileDirname}/../libunp.a",
                     "-lpthread",
                 ],
                 "options": {
                     "cwd": "/usr/bin"
                 }
             }
         ],
         "version": "2.0.0"
     }
    
     {
     // 使用 IntelliSense 了解相关属性。 
     // 悬停以查看现有属性的描述。
     // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
     "version": "0.2.0",
     "configurations": [
         {
             "name": "gcc - 生成和调试活动文件",
             "type": "cppdbg",
             "request": "launch",
             "program": "${fileDirname}/${fileBasenameNoExtension}",
             "args": [],
             "stopAtEntry": false,
             "cwd": "${workspaceFolder}",
             "environment": [],
             "externalConsole": false,
             "MIMode": "gdb",
             "setupCommands": [
                 {
                     "description": "为 gdb 启用整齐打印",
                     "text": "-enable-pretty-printing",
                     "ignoreFailures": true
                 }
             ],
             "preLaunchTask": "gcc build active file",
             "miDebuggerPath": "/usr/bin/gdb"
         }
     ]
     }
    
posted @ 2020-04-17 22:34  zongzi10010  阅读(278)  评论(0编辑  收藏  举报