jambi

导航

 

项目需要串口通讯,github上搜到一个串口库serial,克隆下来编译发现需要用到cmake的catkin模块进行编译,catkin的预编译安装目前只支持ubuntu系统。centos下需要用源码进行编译安装,由于网络资料不全,折腾了很久,记录如下:

1.安装支持环境

1.1 epel扩展源

yum install epel-release -y

1.2 gcc编译器

yum -y install gcc gcc-c++ kernel-devel

1.3 安装openssl

# 1.下载openssl
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
tar -zxvf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a
# 2.编译安装
./config --prefix=/usr/local/openssl no-zlib shared #不需要zlib
make
make install
# 3.备份原配置
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl/ /usr/include/openssl.bak
mv /usr/local/lib64/libssl.so /usr/local/lib64/libssl.so.bak
# 4.新版配置
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# 5.修改系统配置
## 写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
## 使修改后的/etc/ld.so.conf生效 
ldconfig -v

1.4 安装libffi-devel(一定要安装,不然python会报错)

yum install libffi-devel -y

1.5 安装python3.7

wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz
tar -zxvf Python-3.7.12.tgz
mkdir build && cd build
../configure --prefix=/usr/local/Python3712 --enable-optimizations --with-openssl=/usr/local/openssl
make && make install
ln -s /usr/local/Python3712/bin/python3.7 /usr/bin/python3
ln -s /usr/local/Python3712/bin/pip3.7 /usr/bin/pip
ln -s /usr/local/Python3712/bin/pip3.7 /usr/bin/pip3

1.5 cmake

wget https://github.com/Kitware/CMake/archive/refs/tags/v3.18.0-rc4.tar.gz
tar -zxvf v3.18.0-rc4.tar.gz
cd CMake-3.18.0-rc4
./configure --prefix=/usr/local/cmake318
gmake -j2
gmake install
ln -s /usr/local/cmake318/bin/cmake /usr/bin/cmake

1.6 安装gtest

yum install gtest-devel

 

2.安装python依赖包

2.1 安装catkin_pkg

pip install -U catkin_pkg

2.2 安装empty

pip install -U empty

2.3 安装nose

pip install -U nose

3.修改python3 为默认

mv /usr/bin/python /usr/bin/python2.bak
ln -s /usr/local/Python3712/bin/python3.7 /usr/bin/python

3.1 修改yum默认python版本号

vim /usr/bin/yum
将第一行文本由#!/usr/bin/python 修改为 #!/usr/bin/python2
vim /usr/libexec/urlgrabber-ext-down
将第一行文本由#!/usr/bin/python 修改为 #!/usr/bin/python2

 

4.安装catkin

git clone https://github.com/ros/catkin.git
cmake .
make
make install
#如果cmake提示找不到catkin,执行源码中的脚本
python setup.py build
python setup.py install

5.安装结束

posted on 2022-01-07 17:25  jambi  阅读(377)  评论(0编辑  收藏  举报