树莓派3(Raspbian Stretch)安装CMake失败求助
Hey there! Let's work through this CMake issue you're facing. The error you're seeing happens because the 2018-03-13 Raspbian Stretch build uses outdated package sources that have been archived by Debian. Let's start with the most reliable fix, then move to manual extraction if needed.
First: Update Your APT Sources to Use Archived Repositories
Since Stretch is no longer supported, the default sources don't host the packages anymore. We need to point APT to the archive servers:
- Backup your original sources list first (just in case):
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - Edit the sources list file with nano:
sudo nano /etc/apt/sources.list - Replace all existing content with these archive sources:
deb http://archive.debian.org/debian stretch main contrib non-free deb-src http://archive.debian.org/debian stretch main contrib non-free deb http://archive.debian.org/debian-security stretch/updates main contrib non-free deb-src http://archive.debian.org/debian-security stretch/updates main contrib non-free - Save and exit nano (press
Ctrl+O, thenEnter, thenCtrl+X). - Add a config to bypass expired package signature checks (since archive packages are no longer signed with valid dates):
sudo sh -c 'echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/10-nocheckvalid' - Update your package list and try installing again:
sudo apt-get update && sudo apt-get install build-essential cmake pkg-config
If this works, you're all set! If not, let's go with manual extraction of a pre-compiled CMake binary.
Alternative: Manually Install Pre-Compiled CMake (Extracting Library/Binary Files)
This method involves downloading a pre-built CMake package for ARM architectures and copying its files to your system directories:
- Confirm your Raspberry Pi's architecture (should be
armhforarmv7l):uname -m - Download a compatible CMake version (we'll use 3.13.5, which works well with Stretch):
wget https://github.com/Kitware/CMake/releases/download/v3.13.5/cmake-3.13.5-Linux-armhf.tar.gz - Extract the tarball:
tar -xzvf cmake-3.13.5-Linux-armhf.tar.gz - Copy the extracted files to system-wide directories (this "extracts" the library/binary files to where your system can find them):
sudo cp -r cmake-3.13.5-Linux-armhf/bin/* /usr/local/bin/ sudo cp -r cmake-3.13.5-Linux-armhf/lib/* /usr/local/lib/ sudo cp -r cmake-3.13.5-Linux-armhf/share/* /usr/local/share/ - Verify the installation worked:
cmake --version
Note on pip install cmake
Just to clarify: the cmake package on PyPI is a Python wrapper for CMake, not the actual system CMake binary. That's why installing it didn't fix your issue—you need the standalone system tool, not the Python binding.
内容的提问来源于stack exchange,提问作者shawng

