ubuntu20.04安装cmake

配置国内ubuntu源

编辑/etc/apt/sources.list文件, 在文件最前面添加以下条目(操作前做好相应备份)

cd /etc/apt
sudo cp sources.list sources.list.bak
sudo gedit sources.list

增加阿里云,在source.list文件开头增加如下内容


deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

保存并更新

sudo apt update
sudo apt upgrade

安装编译环境

sudo apt install gcc-10  g++-10  build-essential git dkms

下载驱动源码

git clone https://github.com/brektrou/rtl8821CU.git

编译安装

进入项目目录rtl8821CU后开始编译安装

cd rtl8821CU
sudo ./dkms-install.sh

下载cmake3.16.6:https://download.csdn.net/download/qq_46107892/87517469

解压缩:

tar -zxvf cmake-3.16.6-linux-x86_64.tar.gz

配置环境变量

sudo gedit /etc/profile

编辑/etc/profile文件, 在文件末尾加2行:

export CMAKE_HOME=/home/youzhu/Anzen/cmake-3.16.6-Linux-x86_64/bin
export PATH=$CMAKE_HOME:$PATH

刷新环境变量:

source /etc/profile

验证是否能执行CMake

cmake --version

安装源码cmake3.16.6

在/usr/src/目录下新建cmake目录,cd /usr/src/cmake/,将源码下载到此目录,之后都在该目录下操作。
将压缩包解压

 tar xf cmake-3.16.6.tar.gz

修改文件夹权限

sudo chmod -R 777 cmake-3.16.6

进入解压缩的cmake-3.16.6目录 cd cmake-3.16.6

安装build依赖包

sudo apt-get install build-essential
sudo apt-get install libssl-dev

执行

 ./bootstrap

执行

sudo make -j4
sudo make install	

下载:Pangolin

https://github.com/stevenlovegrove/Pangolin/tree/v0.5

安装依赖包:OpenGL,Glew

sudo apt install libgl1-mesa-dev
sudo apt install libglew-dev

创建build文件夹,cd到该目录中

mkdir build && cd build

cmake分析源代码

cmake ..

报错提示

Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY
OPENGL_INCLUDE_DIR)

则需要安装:

sudo apt-fast install libgl1-mesa-dev

make编译源代码

sudo make -j4

make install安装

sudo make install

编译完成后可以测试一下

cd examples/HelloPangolin
./HelloPangolin

你可能感兴趣的:(ubuntu)