Linux平台问题处理笔记

MirrorYuChen
MirrorYuChen
发布于 2024-11-12 / 60 阅读
0
0

Linux平台问题处理笔记

1.Docker容器内log日志中文乱码

  • 系统环境变量配置文件 ~/.zshrc~/.bashrc文件添加
export LANG=C.UTF-8
  • 更新一下环境变量
# 1.bash
>> source ~/.bashrc
# 2.zsh
>> source ~/.zshrc

2.使用clangd插件时出现冲突

You have both the Microsoft C++ (cpptools) extension and clangd extension enabled. 
The Microsoft IntelliSense features conflict with clangd's code completion, diagnostics etc.
  • 处理办法:在 settings.json文件中添加如下内容
	"C_Cpp.intelliSenseEngine": "disabled",
	// 是否检查插件冲突
    "clangd.detectExtensionConflicts": true,
    "clangd.path": "clangd",
    // 查找的头文件路径,每一项前缀 -I
    "clangd.fallbackFlags": [],
    "clangd.arguments": [
        // 在后台自动分析文件(基于complie_commands)
        "--background-index",
        // 标记compelie_commands.json文件的目录位置
        "--compile-commands-dir=build",
        // 同时开启的任务数量
        "-j=12",
        // 全局补全(会自动补充头文件)
        "--all-scopes-completion",
        // 更详细的补全内容
        "--completion-style=detailed",
        // Include what you use
        "--header-insertion=iwyu",
        // pch优化的位置 disk memory
        "--pch-storage=memory",
        "--cross-file-rename",
        "--enable-config",
        // clang-format style to apply by default when no .clang-format file is found
        "--fallback-style=WebKit",
        "--pretty",
        "--clang-tidy",
        "--query-driver=clang++",
    ]
  • 使用clangd跳转时,需要在CMakeLists.txt文件中添加:
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  • 这样会在build文件夹下生成 compile_commands.json文件,帮助我们快速的进行代码跳转。
  • 对于C项目,需要:
# 1.安装compiledb
>> pip install compiledb
# 2.生成compile_commands.json文件
>> compiledb -n make -C build
# 3.编译工程
>> compiledb make -C build

3.一键安装ROS

>> wget http://fishros.com/install -O fishros && . fishros

4.Ubuntu更新报错 apt-secure(8)

  • (1) 错误描述
>> sudo apt-get update
[sudo] admin 的密码: 
忽略:2 https://download.docker.com/linux/ubuntu focal InRelease  
命中:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease  
错误:5 https://download.docker.com/linux/ubuntu focal Release  
  Could not handshake: Error in the pull function. [IP: 18.155.68.17 443]
命中:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease  
命中:4 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
命中:6 http://security.ubuntu.com/ubuntu focal-security InRelease
正在读取软件包列表... 完成
E: 仓库 “https://download.docker.com/linux/ubuntu focal Release” 没有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
  • (2) 处理办法

​ 去ca-certificates官网 下载证书并进行安装

>> wget http://ports.ubuntu.com/pool/main/c/ca-certificates/ca-certificates_20240203~20.04.1_all.deb
>> sudo dpkg -i ca-certificates_20240203~20.04.1_all.deb
>> sudo apt-get update

5.查看Linux平台上库版本

  • 注意下面的方法只能显示使用apt安装的库
# 1.dpkg -l | grep [库名]
>> dpkg -l | grep boost
ii  libboost-all-dev                       1.71.0.0ubuntu2                       amd64        Boost C++ Libraries development files (ALL) (default version)
ii  libboost-atomic-dev:amd64              1.71.0.0ubuntu2                       amd64        atomic data types, operations, and memory ordering constraints (default version)
# 2.使用apt-show-versions工具:apt-show-versions | grep [库名]
>> sudo apt-get install apt-show-versions
>> apt-show-versions | grep boost
libboost-all-dev:amd64/focal 1.71.0.0ubuntu2 uptodate
libboost-atomic-dev:amd64/focal 1.71.0.0ubuntu2 uptodate
  • 需要查看自己源码安装的库,需要使用其自带的工具,如:
>> opencv_version
3.4.16

7.Could NOT find Doxygen (missing: dot)

# 1.安装doxygen
>> sudo apt-get install doxygen
# 2.安装图像化:安装doxygen的过程中缺少这一步
>> sudo apt-get install graphviz

8.wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。

​ (1) 编辑WSL配置文件:C:\Users\Administrator\.wslconfig ,添加如下配置:

[experimental]
autoMemoryReclaim=gradual
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

​ (2) 关闭wsl,然后打开,让配置生效

>> wsl --shutdown

9.ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.

>> python3 -m pip install launchpadlib

10.修改命令行默认配色方式

>> vim ~/.bashrc
PS1='[\[\e[35;1m\]\u@\[\e[33;1m\]\h\[\e[34;1m\] \W\[\e[0m\]]\$ '
>> source ~/.bashrc

11.更换软件源

>> sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
>> sed -i s@/security.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
>> apt-get clean
>> apt-get update

12.numpy报错兼容性

  • (1) 问题信息:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
  • (2) 处理办法,将 numpy降级
>> pip install numpy==1.22.4

参考资料


评论