今天想编译一个源代码,结果不是automake,而是cmake。网上说,先编写CMakeLists.txt,然后执行cmake,再执行make。
我看到源代码里面已经有CMakeLists.txt,所以我直接执行cmake,结果又是一堆的错误。这个时候,我又突然灵光一现,这样执行:cmake CMakeLists.txt,竟然提示:CMake 3.0 or higher is required. You are running version 2.8.12.2
网上很多都说下载源代码,然后编译安装,结果又是有问题。后面找到这个方法:
cd ~/
wget wget https://cmake.org/files/v3.17/cmake-3.17.5-Linux-x86_64.sh
chmod a+x cmake-3.17.5-Linux-x86_64.sh
./cmake-3.17.5-Linux-x86_64.sh #会在当前目录下生成一个文件夹:cmake-3.17.5-Linux-x86_64
vim ~/.bashrc 添加:
PATH=$PATH:/home/ubuntu/cmake-3.17.5-Linux-x86_64/bin
sudo apt-get remove cmake #删除旧的
进入代码文件夹,
cmake CMakeLists.txt
make #到这里可以编译了