常用技术

本文档提供了在Ubuntu环境下安装Python、TensorFlow、OpenCV等软件的详细步骤,并介绍了使用GDB进行C/C++程序调试的方法,以及如何在VSCode中设置Python开发环境。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

about gcc/gcc++

$:sudo apt-cache search "python"
$:sudo apt update
$:sudo apt upgrade
$:sudo apt install aptitude
sptitude install ... will auto install depends 
$:sudo apt-cache depends build-essential
$:sudo aptitude install build-essential
build-essential call install gcc/gcc++ etc.  

about python

  • install tensorflow
1. $: find /usr/bin/ -name "python*"
2. $: python --version
    check the version of python 
3. $: sudo apt-cache search "pip"
4. $: sudo apt install python3-pip
    python2 --> python-pip
    python3 --> python3-pip
5. $: pip3 install tensorflow -i https://mirrors.aliyun.com/pypi/simple  
6. $: ll /usr/bin | grep "python"
7. $: ln -s /usr/bin/python3.6 python
    you may remove python first if exist

about gcc

1. -g must be inserted in compiling process,eg.
    gcc -g -c hello.c -o hello.o
    gcc -O2 hello -o hello.exe
2. 
执行时使用
gdb a
此时输入 l 显示所有的代码
l
输入b 加入断点到某一行(break)
b 108
运行代码到断点处(run)
r
此时输入s单步运行(step )
s
监视某一个变量值的变化
watch ×××
运行直到下一个暂停点(continue)
c
期间输出变量的结果 (print )
p ×××
q退出
3. 
gdb 常用命令
(1) gdb 可执行文件 : 表示对某个文件进行调试
(2) b 函数名/行数  :  在某个函数名或行数前设置断点
(3) run/r          : 表示开始运行,如果是正在调试的程序的话,表示再次进行调试
(4) n/next         : 表示执行下一行语句
(5) l/list         : 列出源码默认10行(当前位置的上下共10行)
    list 行号      : 列出行号上下共10行的源码
    list 函数名    : 列出函数名上下共10行的源码
(6) s/step         : 表示单步执行,进入函数
(7) p /x 变量名    : 按16进制输出变量的值
      /d           : 按10进制
      /o           : 按八进制
(8) set var 变量名=值 : 设置变量的值
(9) bt(backtrace)  : 查看各级函数调用及参数,简写bt
(10)q/quit         : 退出
(11)finish         : 连续运行到当前函数返回为止,然后停下来等待命令
(12)continue/c     : 跳转到下个断点,或者跳转到观察点
(13)ptype 变量名   : 可以查看变量的类型,简写为pt
(14)watch
    作用:一般用来观察某个变量/内存地址的状态(也可以是表达式),
          如可以监控该变量/内存值是否被程序读/写情况。
    有三种方法:
    1.watch expr(指定变量/内存地址/表达式)
    一旦expr的值有变化时,将停住程序。
    2.rwatch expr
    当expr被读时,停住程序。
    3.awatch expr
    当expr被读或被写时,停住程序。
    watch使用步骤:
        1. 使用break在要观察的变量所在处设置断点;
        2. 使用run执行,直到断点;
        3. 使用watch设置观察点;
        4. 使用continue观察设置的观察点是否有变化。
(15)start            : 开始执行程序,停在main函数第一行语句前面等待命令
(16)info watchpoints : 列出所有观察点
    info breakpoints : 查看当前设置的所有断点
(17)d/delete [breakpoinsts num] [rang...]         
    d/delete         : 删除所有断点
    d/delete num     : 删除breakpoints为num的断点
    d/delete num1-num2 : 删除breakpoints为num1-num2的断点
(18)enable num       : 启用num号断点
(19)disable num      : 关闭num号断点
(20)u/until          : 结束当前循环

vscode

prerun: install python compile in vscode, review https://code.visualstudio.com/docs/python/debugging
1. run ubuntu of window
2. $:cd directory  
3. $:code . 
4. command palette(shift+ctrl+p),typing the Python: Select Interpreter ![Uploading file..._xdhptpric]()
5. select the run view
6. Click the create a launch.json file link
7. click the button: run and debug
8. debug....

scp file from linux to windows10

1.install ssh-service in windows 10
    reference website:https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview
2.make ssh key in linux
    ssh-keygen -t rsa -C "tc.yu@moffett.ai"
3.save linux ssh key in ssh server in windows10
    a.创建 authorized_keys 文件并加入公钥
在 PowerShell 中执行 notepad .ssh\authorized_keys 命令创建文本文件,把客户端的公钥复制到这个文件中并保存。
把文本文件的名称修改为 authorized_keys:
    b.修改 ssh 服务的配置文件
以管理员权限打开 PowerShell,执行命令 notepad C:\ProgramData\ssh\sshd_config。
注释掉配置文件中的最后两行然后保存:
#Match Group administrators
#       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
4.run ipconfig in powershell to get ip
5.scp resize_platform.c dell@192.168.1.130:/e:/
  • ssh rsa
reference web:https://blog.youkuaiyun.com/weixin_42125267/article/details/82049763
#两台机器互相免密传输, 先在2台机器上执行1-3步,先把自身的key存入authorized_keys
1. ssh-keygen -t rsa   # 一路回车
2. cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
3. chmod 600 ~/.ssh/authorized_keys
4. ssh-copy-id -i tiancai@192.168.74.11 #登录server12,将公钥拷贝到server11的authorized_keys中
#登录11服务器,执行5, 把uthorized_keys传给12,
5. scp ~/.ssh/authorized_keys tiancai@192.168.74.12:~/.ssh/
#测试,11,12都免密
6. ssh 192.168.74.12

install opencv, install Xwindow in wsl

1.sudo apt install python3-opencv
2.pip install opencv-contrib-python
3.download VcXsrv and install
4.reference: https://blog.youkuaiyun.com/woshiheweigui/article/details/109205369
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值