Giter VIP home page Giter VIP logo

practisec's Introduction

C/C++ practise

ubuntu 修改源路径
vscode 配置 需要执行

apt install build-essentail
apt install gdb ## 用于debug用

task 配置文件

{
    "tasks": [
        {
            "type": "shell",
            "label": "C/C++: gcc build active file",
            "command": "/usr/bin/gcc",
            "args": [
                "-g",
                "-Wall",
                "-Wextra",
                "-std=c99",
                "-o0",
                 "-I${workspaceFolder}/practiseC/include/",
                "${fileDirname}/**",
                "-o",
                "${fileDirname}/../build/${fileBasenameNoExtension}" // 输出可执行文件到那个目录
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "version": "2.0.0"
}

lanch 配置文件

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/../build/${fileBasenameNoExtension}",  // 以点击文件目录查询可执行文件的具体位置
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

git 冲突解决方法

  1. git diff或者git status 查看哪些文件冲突 ,
  2. 解决冲突后执行git add xxx
  3. git branch -M main
  4. git remote add origin [email protected]:TRUMPNUM2/practiseC.git
  5. git push -u origin main
  6. git branch --set-upstream-to origin/main main 合并远程分支与本地分支

常用命令

查看分支:git branch 创建分支:git branch 切换分支:git checkout 创建+切换分支:git checkout -b 合并某分支到当前分支:git merge 删除分支:git branch -d

vsCode+makefile – 调试C

  • tasks.json文件编写
{
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "shell", // 任务名称,与launch.json的preLaunchTask相对应
            "command": "make", // 在shell中使用命令,如需加参数,可再添加args属性
            "type":"shell"
        }
    ]
}
  • launch.json文件编写(用于调用调试程序)
 {
    "version": "0.2.0",
    "configurations": [

        {
            "name": "(gdb) Launch",// 配置名称,将会在启动配置的下拉菜单中显示
            "type": "cppdbg",// 配置类型,这里只能为cppdbg
            "request": "launch",// 请求配置类型,可以为launch(启动)或attach(附加)
            "program": "${workspaceRoot}/test",// 将要进行调试的程序的路径
            "stopAtEntry": true, // 设为true时程序将暂停在程序入口处,我一般设置为true
            "cwd": "${workspaceRoot}",// 调试程序时的工作目录
            "environment": [],// (环境变量?)
            "externalConsole": true,// 调试时是否显示控制台窗口,一般设置为true显示控制台
            "MIMode": "gdb",// 指定连接的调试器,可以为gdb或lldb。
            "preLaunchTask": "shell" // 调试会话开始前执行的任务,一般为编译程序。与tasks.json的taskName相对应,可根据需求选择是否使用
        }
    ]
}

-g:为调试使用 -c:仅编译(Compile),不连接(Make) -o:输出文件名

如果 出现 error while loading shared libraries: libmytest.so: cannot open shared object file: No such file or directory 说明动态的链接库没有被系统识别 vim /etc/ld.so.conf //在新的一行中加入库文件所在目录 include /etc/ld.so.conf.d/*.conf 修改这个里面的文件,添加自己编译的之后的动态库,执行 ldconfig 即可生效 /usr/lib

ldconfig //更新/etc/ld.so.cache文件

practisec's People

Contributors

jaibreaker avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.