Chemmy's Blog

chengming0916@outlook.com

在使用 Qt 开发时,qDebug 打印包含中文的 QString 可能会出现乱码。这通常是由于字符编码不一致导致的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <QDebug>
#include <QTextCodec>
#include <Windows.h>

int main() {

//设置QTextCodec
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec);

// 将字符串转换为 UTF-8 编码,然后再传递给 qDebug 打印。
qDebug() << QString::fromUtf8(u8"你好,世界!");
return 0;
}

系统要求

  • 操作系统: Ubuntu 18.04 (Bionic Beaver)
  • ROS 版本: Melodic Morenia (官方长期支持版本)
  • Python 版本: 2.7.x (ROS Melodic 默认使用)

安装步骤

1. 配置软件源和密钥

1
2
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

2. 更新软件包列表

1
sudo apt update

3. 安装 ROS Melodic

完整桌面版 (推荐,包含 GUI 工具、仿真器和常用库):

1
sudo apt install ros-melodic-desktop-full

其他可选版本:

1
2
sudo apt install ros-melodic-desktop    # 基础桌面版(无仿真器)
sudo apt install ros-melodic-ros-base # 最小核心版(仅通信库和工具)

4. 初始化 rosdep

1
2
sudo rosdep init
rosdep update

5. 设置环境变量

1
2
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

6. 安装构建工具和依赖

1
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

7. 创建示例工作空间 (可选)

1
2
3
4
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make
source devel/setup.bash

验证安装

打开新终端,运行:

1
roscore

如果看到类似以下输出,说明安装成功:

1
2
3
4
5
6
7
... logging to /home/username/.ros/log/xxx/roslaunch-hostname-xxx.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://hostname:xxx/
ros_comm version 1.14.3

常见问题解决

1. 密钥获取失败

如果 apt-key adv 失败,可以手动下载并添加:

1
curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -

2. 网络问题

如果下载速度慢,可以替换为国内镜像源(如清华源):

1
sudo sh -c '. /etc/lsb-release && echo "deb https://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'

3. Python 版本验证

确保系统中已安装 Python 2.7:

1
python --version  # 应显示 Python 2.7.x

测试命令

安装完成后,可以使用以下命令测试 ROS 功能:

  • roscore - 启动 ROS master
  • rosrun roscpp_tutorials talker - 运行发布者节点
  • rosrun roscpp_tutorials listener - 运行订阅者节点

参考资源

概述

LIO-SAM (Lidar Inertial Odometry and Mapping) 是一个紧耦合的激光雷达惯性里程计框架,集成了 IMU 预积分和 GPS 数据,适用于机器人建图和定位。

环境要求

组件 版本 下载地址
Ubuntu 18.04+ -
ROS Melodic -
gtsam 4.0.2 GitHub
Eigen 3.3.7 GitLab
LIO-SAM 最新版 GitHub

安装步骤

1. 安装系统依赖

1
2
3
4
5
# 更新系统包列表
sudo apt update

# 安装必要的开发工具和依赖库
sudo apt install -y build-essential cmake libboost-all-dev

2. 安装 Eigen 库

1
2
3
4
5
6
7
8
9
10
11
12
# 下载并解压 Eigen
wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz
tar -zxvf eigen-3.3.7.tar.gz

# 编译安装
cd eigen-3.3.7
mkdir build && cd build
sudo cmake ..
sudo make install

# 创建符号链接以便系统找到 Eigen 头文件
sudo cp -r /usr/local/include/eigen3/Eigen/ /usr/local/include/

3. 安装 ROS Melodic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 设置 ROS 软件源(清华镜像)
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

# 添加 ROS 密钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

# 更新包列表并安装 ROS
sudo apt update
sudo apt-get install -y ros-melodic-desktop-full

# 安装 ROS 开发工具
sudo apt-get install -y ros-melodic-rqt* python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential

# 初始化 rosdep
sudo rosdep init
rosdep update

4. 配置 ROS 环境

1
2
3
# 将 ROS 环境变量添加到 bashrc
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

5. 安装 gtsam

1
2
3
4
5
6
7
8
9
10
11
12
# 克隆 gtsam 仓库
git clone https://github.com/borglab/gtsam.git
cd gtsam

# 切换到 4.0.2 版本
git checkout 4.0.2

# 编译安装
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install

6. 安装 LIO-SAM

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 创建工作空间
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src

# 克隆 LIO-SAM
git clone https://github.com/TixiaoShan/LIO-SAM.git

# 安装依赖
cd ~/catkin_ws
rosdep install --from-paths src --ignore-src -y

# 编译
catkin_make -j$(nproc)

# 设置工作空间环境
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

验证安装

测试 ROS 安装

1
2
3
4
5
# 启动 ROS 核心
roscore

# 新终端中检查 ROS 环境
echo $ROS_PACKAGE_PATH

测试 LIO-SAM 编译

1
2
3
4
5
# 检查 LIO-SAM 包是否存在
rospack find lio_sam

# 尝试运行节点(需要相应的启动文件)
roslaunch lio_sam run.launch

常见问题解决

1. Eigen 头文件找不到

问题:编译时出现 fatal error: Eigen/Dense: No such file or directory

解决方案

1
2
# 确保 Eigen 头文件在正确位置
sudo ln -s /usr/local/include/eigen3/Eigen /usr/local/include/Eigen

2. gtsam 版本不兼容

问题:需要特定版本的 gtsam

解决方案

1
2
3
# 确保使用 gtsam 4.0.2 版本
cd gtsam
git checkout 4.0.2

3. ROS 依赖问题

问题:缺少 ROS 包依赖

解决方案

1
2
# 安装所有缺失的依赖
rosdep install --from-paths src --ignore-src -y

使用说明

启动 LIO-SAM

1
2
3
4
5
# 启动 LIO-SAM 主要节点
roslaunch lio_sam run.launch

# 启动可视化工具
roslaunch lio_sam visualization.launch

数据播放

1
2
# 播放 bag 文件
rosbag play your_data.bag

目录结构

1
2
3
4
5
6
7
~/catkin_ws/
└── src/
└── LIO-SAM/
├── config/ # 配置文件
├── launch/ # 启动文件
├── src/ # 源代码
└── package.xml # ROS 包配置

注意事项

  1. 版本匹配:确保所有组件的版本兼容性
  2. 内存要求:编译过程需要足够的内存,建议 8GB+ RAM
  3. 网络连接:下载依赖需要稳定的网络连接
  4. 权限问题:某些操作需要 sudo 权限

后续步骤

  1. 配置参数:根据你的传感器调整 config/params.yaml
  2. 数据采集:使用你的传感器采集数据
  3. 性能调优:根据实际场景调整算法参数

参考资源

准备

建议准备一个干净、换好源的 Ubuntu 16.04 及以上版本(建议 清华源 ),本教程也适用其他 ROS1版本。

查看ubuntu 版本

1
lsb_release -a

根据自己的 Ubuntu 的版本选择 ROS 版本 (示例是 Ubuntu 18.04 所以对应ROS版本为 melodic
![[Ubuntu部署ROS/IMG-20250829234441526.png]]

ROS安装

1. 安装源

1
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'

2. 设置密钥

1
2
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

3. 安装

1
2
3
4
sudo apt update
sudo apt install ros-melodic-desktop
# 其他版本替换对应的版本(例如 noetic )
# sudo apt install ros-noetic-desktop

4. 配置环境变量

1
2
3
4
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc #使环境生效
# 替换对应版本同上
# echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc

5. 配置rosdep

在使用许多 ROS 工具之前,需要初始化 rosdep,有些功能包源码编译需要rosdep 来安装这些系统依赖项,不配置也不影响ros使用,所以后面需要时再来配置也可以。 rosdep 请求的文件都放在 github 上的, 推荐使用代理。

1
2
3
4
5
6
7
8
9
10

# 安装依赖
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
# 对于Ubuntu20
# sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential

# 初始化
sudo rosdep init
rosdep update

测试

1
2
3
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

参考
官方文档(melodic)
ubuntu18.04安装ROS Melodic(最详细配置)-CSDN博客
基于Ubuntu18.04的ROS Melodic环境详细配置(含各种大坑及填坑)
[ROS 系列学习教程] ROS与操作系统版本对应关系_ros版本-CSDN博客

1. K3s指定集群管理IP

在k3s.service中添加启动参数

1
--advertise-address=<192.168.x.x>

详细参考官方文档以及 K3S安装

查看当前Context

1
kubectl config current-context

2. 配置集群信息

查看context列表

1
kubectl config get-contexts

输出中带有*的Context表示当前活动的Context

切换到指定Context

1
2
3
4
5
kubectl config use-context <context_name>

# 示例:切换到dev-ctx
kubectl config use-context dev-ctx

在指定Context中执行命令,一般用于临时使用

1
2
3
4
kubectl  --context=<context_name> <exec_cmd>

# 示例:在dev-ctx下执行get pods
kubectl --context=dev-ctx get pods

3. 合并配置文件

在 Kubernetes 环境中,使用 kubectl 管理多个集群非常常见。通过配置 kubeconfig 文件,可以轻松切换和管理多个集群。以下是实现方法的详细步骤。

方法 1: 合并多个配置文件

  • 准备配置文件 假设已有两个集群的配置文件:_/.kube/config1_ 和 _/.kube/config2_。

  • 合并配置文件 使用以下命令将多个配置文件合并为一个:

KUBECONFIG=/.kube/config1:/.kube/config2 kubectl config view –merge –flatten > ~/.kube/config

  • 验证合并结果 查看合并后的配置:

kubectl config view

方法 2: 配置环境变量

  • 设置环境变量 将多个配置文件路径添加到 KUBECONFIG 环境变量中:

export KUBECONFIG=/.kube/config:/.kube/test-config

  • 验证配置 执行以下命令查看所有集群信息:

kubectl config get-contexts

方法 3: 手动编辑配置文件

  • 打开配置文件 编辑 ~/.kube/config 文件,将其他集群的 cluster_、_context 和 user 信息粘贴到现有配置中。

  • 格式示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

apiVersion: v1

clusters:

- cluster:

server: https://127.0.0.1:6443

name: cluster1

- cluster:

server: https://192.168.0.1:6443

name: cluster2

contexts:

- context:

cluster: cluster1

user: user1

name: context1

- context:

cluster: cluster2

user: user2

name: context2

current-context: context1

切换集群上下文

  • 查看当前上下文:

    1
    kubectl config current-context
  • 切换到其他上下文:

    1
    2

    kubectl config use-context <context_name>

    最佳实践

  • 使用合并或环境变量的方法更高效,避免手动编辑出错。

  • 定期备份 kubeconfig 文件,防止误操作导致数据丢失。

  • 确保每个集群的访问凭证和权限正确无误。

通过以上方法,您可以轻松管理多个 Kubernetes 集群,提高运维效率。

大家好!在 云原生 的世界里,和 Kubernetes 打交道是家常便饭。如果我们像我一样,需要同时管理多个 Kubernetes 集群——比如一个用于严谨发布的 生产环境 ,一个用于大胆实验的 测试环境 ,甚至还有本地开发环境——那么高效、安全地在它们之间切换就成了必备技能。

很多朋友(包括我自己有时也会!)可能会因为一段时间没用而忘记 kubectl 中那些用于切换配置的命令。别担心,这很正常!今天,我们就来系统地回顾一下 kubectl 配置管理的核心概念—— 上下文(Context) ,以及如何利用它在不同集群间自如切换。

核心概念:kubeconfig 文件与上下文(Context)

kubectl 的所有配置信息都存储在一个或多个 YAML 文件中,默认情况下是 $HOME/.kube/config 。这个文件我们通常称为 kubeconfig 文件。把它想象成我们的 Kubernetes “护照”,里面记录了我们能访问哪些集群,用什么身份访问。

一个 kubeconfig 文件通常包含三个主要部分:

  1. Clusters(集群) :定义了我们要连接的 Kubernetes 集群的信息,比如 API Server 的地址和集群的 CA 证书。
  2. Users(用户) :定义了访问集群所使用的凭证,可能是用户名/密码、Token 或客户端证书。
  3. Contexts(上下文) :这是连接 集群用户 的桥梁。一个 Context 定义了使用哪个 User 凭证去访问哪个 Cluster。

关键点: 我们可以通过切换 Context 来改变 kubectl 当前操作的目标集群和使用的身份。

管理 kubeconfig 的常用 kubectl config 命令

kubectl 提供了一套 config 子命令来帮助我们查看和管理 kubeconfig 文件。以下是几个最核心、最常用的命令:

1. 查看当前配置:kubectl config view

这个命令会显示我们当前的 kubeconfig 文件内容(或者合并后的内容,如果我们配置了多个文件)。它会隐藏敏感信息(如证书和 Token 的具体内容),非常适合快速检查配置概览。

1
2
kubectl config view
bash1

如果我们想看某个特定 Context 的详细信息,可以加上 --context 参数:

1
2
3
# 查看名为 'prod-cluster' 的 context 细节
kubectl config view --context=prod-cluster
bash12
2. 列出所有可用的上下文:kubectl config get-contexts

这是 最常用 的命令之一,它会列出我们在 kubeconfig 文件中定义的所有 Context。当前正在使用的 Context 会在名称前用星号 * 标记。

1
2
3
4
5
6
7
kubectl config get-contexts
# 输出示例:
# CURRENT NAME CLUSTER AUTHINFO NAMESPACE
# * test-cluster kubernetes-test user-test
# prod-cluster kubernetes-prod user-prod production
# docker-desktop docker-desktop docker-desktop
bash123456

从上面的输出可以清晰地看到:

  • 当前激活的 Context 是 test-cluster
  • 还有名为 prod-clusterdocker-desktop 的 Context 可供切换。
3. 查看当前使用的上下文:kubectl config current-context

如果我们只想快速确认当前 kubectl 命令会作用于哪个 Context(哪个集群),这个命令最直接:

1
2
3
4
kubectl config current-context
# 输出示例:
# test-cluster
bash123
4. 切换上下文:kubectl config use-context

这绝对是 核心中的核心 !当我们需要将 kubectl 的操作目标从一个集群切换到另一个集群时,就使用这个命令。

假设我们想从当前的 test-cluster 切换到 prod-cluster

1
2
3
4
kubectl config use-context prod-cluster
# 输出示例:
# Switched to context "prod-cluster".
bash123

切换成功后,我们可以再次使用 kubectl config current-contextkubectl config get-contexts 来验证当前上下文是否已更改。

1
2
3
4
5
6
7
8
9
10
11
kubectl config current-context
# 输出示例:
# prod-cluster

kubectl config get-contexts
# 输出示例:
# CURRENT NAME CLUSTER AUTHINFO NAMESPACE
# test-cluster kubernetes-test user-test
# * prod-cluster kubernetes-prod user-prod production
# docker-desktop docker-desktop docker-desktop
bash12345678910

现在,所有后续的 kubectl 命令(如 kubectl get pods, kubectl apply -f ... 等)都会默认发送到 prod-cluster 所定义的集群,并使用 user-prod 的身份进行认证。

实践场景:在生产和测试集群间切换

假设我们的 kubeconfig 文件中已经配置好了代表生产环境和 测试环境 的 Context,可能分别命名为 productiontesting

我们的日常操作流程可能是这样的:

  1. 检查当前在哪:
    1
    2
    kubectl config current-context
    bash1
    或者看列表:
    1
    2
    kubectl config get-contexts
    bash1
  2. 需要操作测试环境:
    1
    2
    3
    4
    5
    6
    kubectl config use-context testing
    # 验证一下(可选但推荐)
    kubectl config current-context
    # 现在可以对测试环境执行操作了
    kubectl get pods -n test-namespace
    bash12345
  3. 需要紧急处理生产环境问题:
    1
    2
    3
    4
    5
    6
    kubectl config use-context production
    # 验证一下
    kubectl config current-context
    # 操作生产环境(请务必小心!)
    kubectl get deployment -n critical-app
    bash12345
  4. 完成生产环境操作,切回测试环境继续工作:
    1
    2
    kubectl config use-context testing
    bash1

提升效率的小贴士

  1. 清晰命名 Context :给我们的 Context 起一个能清晰表明环境和用途的名字,比如 gke-prod-eu, eks-dev-us, local-minikube 等。避免使用模糊不清的名字。
  2. 使用 Shell 别名 :很多人喜欢为 kubectl 设置别名,比如 alias k=kubectl 。这样我们的命令可以更短: k config get-contexts, k config use-context my-context
  3. 考虑使用辅助工具 :社区有一些流行的小工具可以让我们更方便地切换 Context 和 Namespace,例如:
    • kubectx (用于切换 Context)
    • kubens (用于切换 Namespace)
      这些工具通常提供交互式选择或更简洁的命令,可以显著提高效率。可以通过包管理器(如 Homebrew, apt, yum)或直接下载二进制文件来安装它们。
  4. 注意 kubeconfig 文件的安全性kubeconfig 文件包含了访问集群的凭证,务必妥善保管,不要泄露给未授权的人员。

总结

管理多个 Kubernetes 集群配置并不复杂,核心就在于理解和运用 kubeconfig 文件中的 Context 概念。通过掌握 kubectl config 的几个关键子命令:

  • view: 查看配置概览
  • get-contexts: 列出所有可用上下文
  • current-context: 显示当前激活的上下文
  • use-context <context-name>: 切换到指定的上下文

我们就能轻松地在不同的 Kubernetes 环境(如生产和测试)之间安全、高效地切换了。希望这篇回顾能帮我们重新找回操作 kubectl 多集群配置的熟悉感!

一、先来看一篇转载文章《在 VS2015 中使用 Qt4

http://tangzx.qiniudn.com/post-0111-qt4-vs2015.html 最早的原文,看不到了

https://github.com/district10/qt4-vs2015x64 原作者的github,里面的东东都下载不了了

二、firecat本人的教程

0、Qt官方

Qt4.8.7官方源码下载

https://download.qt.io/new_archive/qt/4.8/4.8.7/

官网的exe只提供了MSVC2010,没有更高版本的。高版本需要自己下载源码编译。

源码里面的配置文件已经提供了MSVC 2015的编译选项,\qt-everywhere-opensource-src-4.8.7\mkspecs\win32-msvc2015

参照官方提供的编译文档一步一步执行即可;但是配置文件里没有提供MSVC 2017的编译选项。

官方编译的文档

https://doc.qt.io/archives/qt-4.8/installation.html

https://doc.qt.io/archives/qt-4.8/configure-options.html

https://doc.qt.io/archives/qt-4.8/install-win.html

https://doc.qt.io/archives/qt-4.8/install-mac.html

https://doc.qt.io/qt-5/build-sources.html

1、Qt 4.8.7+MSVC 2017

推荐使用第三方提供的源码,它已经是修改好的,里面含有MSVC 2017编译选项,可以编译。

https://github.com/scharsig/Qt Qt4.8.7+MSVC2017源码

https://forum.qt.io/topic/91623/building-qt-4-8-7-with-visual-studio-2017 Qt4.8.7+MSVC2017论坛

https://github.com/sandym/qt-patches 仅供参考,编译补丁

https://github.com/Homebrew/formula-patches/tree/master/qt 仅供参考,编译补丁

https://github.com/BartVandewoestyne/qt_4_8_7_with_vs2017_patch 仅供参考,编译补丁

完整的编译过程:

下载第三方源码https://github.com/scharsig/Qt/tree/master/qt-4.8.7-vs2017 然后解压

-–step1—

Windows桌面-开始-程序-Visual Studio 2017-Visual Studio Tools-VC-x86 Native Tools Command Prompt for VS 2017

-–step2—

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise>cd F:\Qt\setup-exe\4.8.7\Qt-master\qt-4.8.7-vs2017

-–step3—

F:\Qt\setup-exe\4.8.7\Qt-master\qt-4.8.7-vs2017>configure -help

-–step4—

F:\Qt\setup-exe\4.8.7\Qt-master\qt-4.8.7-vs2017>
configure -make nmake -debug-and-release -opensource -confirm-license -platform win32-msvc2017 -prefix F:\Qt\Qt4.8.7-msvc2017 -nomake examples -nomake tests

如果不想编译这么多功能模块,可以精简为:

configure -make nmake -debug-and-release -opensource -confirm-license -platform win32-msvc2017 -prefix F:\Qt\Qt4.8.7-msvc2017 \
  -no-qt3support -no-multimedia \
  -no-audio-backend -no-phonon -no-phonon-backend -no-libtiff \
  -no-libmng -no-dbus -no-nis -nomake examples -nomake tests

 -release              Compile and link Qt with debugging turned off. -debug                Compile and link Qt with debugging turned on. -nomake tests         Disable building of tests to speed up compilation -nomake examples      Disable building of examples to speed up compilation -confirm-license      Automatically acknowledge the LGPL 2.1 license.

-–step5—

F:\Qt\setup-exe\4.8.7\Qt-master\qt-4.8.7-vs2017>nmake

-–step6—

F:\Qt\setup-exe\4.8.7\Qt-master\qt-4.8.7-vs2017>nmake install

-–step7—

添加到Qt Creator

![[编译Qt 4.8.7源码/IMG-20250807081809727.png]]

-–step8—

新建项目测试,Qt Creator+Qt4.8.7+MSVC2017编译项目时,如果报错:

intermediate\moc\moc_rs_actionzoompan.cpp:-1: error: C1041: 无法打开程序数据库“F:\CADCAM\QCAD\src\build-LibreCAD-v1.0.4-qt4-Desktop_Qt_4_8_7_MSVC2017_32bit-Debug\librecad\vc140.pdb”;如果要将多个 CL.EXE 写入同一个 .PDB 文件,请使用 /FS

解决办法:

在Qt Creator的项目文件,即.pro文件中,可以通过QMAKE_CXXFLAGS来给MSVC编译器传递编译开关。

QMAKE_CXXFLAGS += /FS

win32-msvc*:QMAKE_CXXFLAGS += /wd"4819" QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings 

MSVC 2017编译器常见错误的解决:

https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/c-cpp-build-errors?view=vs-2017

2、Mac OS+Qt 4.8.7

笔者的Mac OS版本是MacOS-10.15-Catalina,高版本的OS和Clang已经不再支持Qt官方发布的Qt4了。

解决办法可以参见我的另一篇博文:https://blog.csdn.net/libaineu2004/article/details/104740623

https://trac.macports.org/ticket/58651 mac下编译qt4遇到问题

https://github.com/macports/macports-ports/tree/master/aqua/qt4-mac mac编译补丁

方法1: 为当前用户设置环境变量

为当前用户设置 HTTP_PROXY 和 HTTPS_PROXY 环境变量,Podman 将自动读取这些环境变量并使用代理。

1
2
3
4
5
6
7
8
9
10
11
# Bash
export HTTP_PROXY="http://代理地址:端口"
export HTTPS_PROXY="https://代理地址:端口"

# 对于 bash, 也可以在 ~/.bashrc 中添加上述命令使其永久有效

# Fish
set -x HTTP_PROXY "http://代理地址:端口"
set -x HTTPS_PROXY "https://代理地址:端口"

# 对于 fish,也可以在 ~/.config/fish/config.fish 中添加以上命令

如果代理需要身份验证,可以在 URL 中添加用户名和密码。格式如下:

1
http://用户名:密码@代理地址:端口

方法2:为 Podman 服务设置配置文件

通过编辑 /etc/containers/registries.conf 配置文件为 Podman 服务设置代理。在该文件中添加如下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[registries.search]
registries = ['docker.io', 'quay.io']

[registries.insecure]
registries = []

[registries.block]
registries = []

[registries.unqualified-search-registries]

[registry.mirrors]

[registry.configs]

[registry.configs.REGISTRY_NAME.HOSTNAME/HOSTPATH]
unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "docker.io"]
blocked=false

[registry.configs.REGISTRY_NAME.HOSTNAME]
http-proxy="http://代理地址:端口"
https-proxy="https://代理地址:端口"

替换 REGISTRY_NAME.HOSTNAME 为您要配置的注册表,如 docker.io。如果代理需要身份验证,则使用类似 http://user:password@proxy.example.com:8080 的格式。

方法3: 为单个 Podman 命令设置代理

为单个 Podman 命令临时设置代理,方法是在命令前添加 –build-arg 参数。例如:

1
podman --build-arg HTTP_PROXY="http://代理地址:端口" --build-arg HTTPS_PROXY="https://代理地址:端口" pull nginx

方法四: 配置 http-proxy.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ systemctl status podman
● podman.service - Podman API Service
Loaded: loaded (/usr/lib/systemd/system/podman.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/podman.service.d
└─http-proxy.conf
Active: inactive (dead) since Mon 2023-11-20 18:45:12 CST; 3 months 22 days ago
Docs: man:podman-system-service(1)
Process: 50669 ExecStart=/usr/bin/podman $LOGGING system service (code=exited, status=0/SUCCESS)
Main PID: 50669 (code=exited, status=0/SUCCESS)

Nov 20 18:45:07 downlaod systemd[1]: Starting Podman API Service...
Nov 20 18:45:07 downlaod systemd[1]: Started Podman API Service.
Nov 20 18:45:07 downlaod podman[50669]: time="2023-11-20T18:45:07+08:00" level=info msg="/usr/bin/podman filtering at log level>
Nov 20 18:45:07 downlaod podman[50669]: time="2023-11-20T18:45:07+08:00" level=info msg="Not using native diff for overlay, thi>
Nov 20 18:45:07 downlaod podman[50669]: time="2023-11-20T18:45:07+08:00" level=info msg="Setting parallel job count to 13"
Nov 20 18:45:07 downlaod podman[50669]: time="2023-11-20T18:45:07+08:00" level=info msg="Using systemd socket activation to det>
Nov 20 18:45:07 downlaod podman[50669]: time="2023-11-20T18:45:07+08:00" level=info msg="API service listening on \"/run/podman>
Nov 20 18:45:12 downlaod systemd[1]: podman.service: Succeeded.

$ cat /etc/systemd/system/podman.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://192.168.21.101:7890"
Environment="HTTPS_PROXY=http://192.168.21.101:7890"
Environment="NO_PROXY=localhost,127.0.0.1,.coding.net,.tencentyun.com,.myqcloud.com,harbor.bsgchina.com"

  1. 安装依赖环境

    1
    2
    3
    4
    5
    6
    7
    8
    # 启用虚拟化平台
    dism /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

    # 启用linux子系统
    dism /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all

    wsl --install
    wsl --update
  2. 安装Podman

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    # 安装DockerCLI,用于兼容Docker命令
    winget install --id Docker.DockerCLI

    # 安装Podman
    winget install --id RedHat.Podman

    # 安装Podman Desktop (可选)
    winget install --id RedHat.Podman-Desktop

    # 初始化Podman
    podman machine init

    # 配置端口转发
    wsl sudo sysctl net.ipv4.ip_forward=1
  3. 配置wsl虚拟机

    1
    2
    3
    4
    5
    6
    7
    # 修改默认软件源
    sudo sed -e 's|^metalink=|#metalink=|g' \
    -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora|g' \
    -i.bak \
    /etc/yum.repos.d/fedora.repo \
    /etc/yum.repos.d/fedora-updates.repo
    sudo dnf makecache
  4. 测试

    1
    docker run --rm -d -p 80:80 --name httpd docker.io/library/httpd:latest
  5. 配置镜像加速
    podman的配置文件在容器内 /etc/containers/registries.conf,配置格式如下

    1
    2
    3
    4
    5
    unqualified-search-regustrues = ["docker.io"]

    [[registry]] # 注意此处配置不需要加'https'
    prefix = "docker.io" # 访问地址
    location = "docker.m.daocloud.io" # 加速地址
  6. 配置私有镜像库

1
2
3
[[registry]]
location = "harbor.example.io"
insecure = true

如果访问地址为https需要配置信任证书

1
2
sudo mkdir /etc/containers/certs.d
sudo cp <path to cert> /etc/containers/certs.d/ca.crt
  1. 配置文件翻译
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    # 有关此配置文件的更多信息,请参阅 containers-registries.conf(5)。
    #
    # 注意:使用未完全限定镜像名称的风险
    # 我们建议始终使用包括注册表服务器(完整 DNS 名称)、命名空间、镜像名称和标签在内的完全限定镜像名称
    # (例如,registry.redhat.io/ubi8/ubi:latest)。通过摘要(例如,
    # quay.io/repository/name@digest)拉取镜像可以进一步消除标签的不确定性。
    # 使用短名称时,始终存在镜像被伪造的风险。例如,用户想从某个注册表中拉取名为
    # `foobar` 的镜像,并期望该镜像来自 myregistry.com。如果
    # myregistry.com 不是搜索列表中的第一个,攻击者可能会在列表中靠前的位置
    # 放置另一个名为 `foobar` 的镜像。用户可能会意外拉取并运行攻击者的镜像和代码,而不是
    # 预期的内容。我们建议只添加完全可信的注册表(即,不允许未知或匿名用户
    # 创建任意名称的账户的注册表)。这将防止镜像被伪造、抢占或以其他方式变得不安全。
    # 如果有必要使用这些注册表,它应该添加到列表的末尾。
    #
    # # 一个主机[:端口]格式的注册表数组,当拉取未完全限定镜像时,按顺序尝试这些注册表。
    unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "docker.io"]
    #
    # [[registry]]
    # # "prefix" 字段用于选择相关的 [[registry]] TOML 表;
    # # 使用输入镜像名称时,只有与该名称最长匹配的 TOML 表会被使用
    # # (考虑到命名空间/库/标签/摘要分隔符)。
    # #
    # # 如果缺少 prefix 字段,则默认与 "location" 字段相同。
    prefix = "example.com/foo"
    #
    # # 如果为 true,则允许未加密的 HTTP 连接以及使用不受信任证书的 TLS 连接。
    insecure = false
    #
    # # 如果为 true,则禁止拉取匹配名称的镜像。
    blocked = false
    #
    # # "prefix" 所在命名空间的物理位置。
    # #
    # # 默认情况下,与 "prefix" 相同(在这种情况下,可以省略 "prefix",并且 [[registry]] TOML 表只指定 "location")。
    # #
    # # 例如:假设
    # # prefix = "example.com/foo"
    # # location = "internal-registry-for-example.net/bar"
    # # 那么对镜像 example.com/foo/myimage:latest 的请求实际上会与
    # # internal-registry-for-example.net/bar/myimage:latest 镜像匹配。
    location = "internal-registry-for-example.com/bar"
    #
    # # "prefix" 所在命名空间的(可能部分的)镜像。
    # #
    # # 将按指定顺序尝试这些镜像;第一个可以联系到并包含镜像的将被使用
    # # (如果所有镜像都没有该镜像,则最后尝试 "registry.location" 字段指定的主位置,或者使用未修改的用户指定引用)。
    # #
    # # "mirror" 数组中的每个 TOML 表可以包含以下字段,语义与直接在 [[registry]] TOML 表中指定的相同:
    # # - location
    # # - insecure
    [[registry.mirror]]
    location = "example-mirror-0.local/mirror-for-foo"
    [[registry.mirror]]
    location = "example-mirror-1.local/mirrors/foo"
    insecure = true
    # # 根据上述配置,拉取 example.com/foo/image:latest 时将按顺序尝试:
    # # 1. example-mirror-0.local/mirror-for-foo/image:latest
    # # 2. example-mirror-1.local/mirrors/foo/image:latest
    # # 3. internal-registry-for-example.net/bar/image:latest
    # # 并使用第一个存在的镜像。
    #
    # short-name-mode="enforcing"
    # 强制使用完全限定镜像名称

    [[registry]]
    location="localhost:5000"
    insecure=true
    # 允许使用不安全的连接拉取本地镜像。

1. Co., Ltd.

  • 全称:Company Limited
  • 含义:有限责任公司,常见于英国、中国及亚洲地区
  • 特点:”Co.“为Company缩写,”.“表示缩写符号,”,”用于分隔前后词

2. Inc.

  • 全称:Incorporated
  • 含义:股份有限公司,多用于美国、加拿大
  • 示例:Apple Inc.,强调股东责任限于股份投资

3. LLC

  • 全称:Limited Liability Company
  • 含义:有限责任公司(美国特有形式)
  • 特点:兼具合伙制灵活性与股份制有限责任,如Google LLC

4. GmbH

  • 全称:Gesellschaft mit beschränkter Haftung
  • 含义:有限责任公司,德国及德语区专用
  • 示例:Bosch GmbH1

5. AG

  • 全称:Aktiengesellschaft
  • 含义:股份有限公司,德国及瑞士常见
  • 示例:BMW AG

6. S.A.

- 全称:Société Anonyme(法)/Sociedad Anónima(西)
- 含义:股份有限公司,流行于法国、西班牙等拉丁语系国家
- 示例:L’Oréal S.A.1

7. Plc

  • 全称:Public Limited Company
  • 含义:公众有限公司(英国上市企业专用)
  • 示例:HSBC Holdings plc1

8. 株式会社(Kabushiki Kaisha)

  • 缩写:KK
  • 含义:日本股份有限公司
  • 示例:Toyota Motor Corporation KK

地域差异提示

  • 英国”Ltd.”与美国”LLC”虽均表有限责任,但法律结构不同
  • 荷兰用”BV”(私人有限公司),意大利用”S.p.A.”(股份公司)
0%