sh 为Raspberry PI安装GCC 8.1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 为Raspberry PI安装GCC 8.1相关的知识,希望对你有一定的参考价值。

#!/bin/bash

#
#  This is the new GCC version to install.
#
VERSION=8.1.0

#
#  For the Pi or any computer with less than 2GB of memory.
#
if [ -f /etc/dphys-swapfile ]; then
  sudo sed -i 's/^CONF_SWAPSIZE=[0-9]*$/CONF_SWAPSIZE=1024/' /etc/dphys-swapfile
  sudo /etc/init.d/dphys-swapfile stop
  sudo /etc/init.d/dphys-swapfile start
fi

if [ -d gcc-$VERSION ]; then
  cd gcc-$VERSION
  rm -rf obj
else
  wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$VERSION/gcc-$VERSION.tar.xz
  tar xf gcc-$VERSION.tar.xz
  cd gcc-$VERSION
  contrib/download_prerequisites
fi
mkdir -p obj
cd obj

#
#  Now run the ./configure which must be checked/edited beforehand.
#  Uncomment the sections below depending on your platform.  You may build 
#  on a Pi3 for a target Pi Zero by uncommenting the Pi Zero section.
#  To alter the target directory set --prefix=<dir>
#

# Pi3+, Pi3, and new Pi2
../configure --enable-languages=c,c++ --with-cpu=cortex-a53 \
  --with-fpu=neon-fp-armv8 --with-float=hard --build=arm-linux-gnueabihf \
  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-checking=no

# Pi Zero's
#../configure --enable-languages=c,c++ --with-cpu=arm1176jzf-s \
#  --with-fpu=vfp --with-float=hard --build=arm-linux-gnueabihf \
#  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-checking=no

# x86_64
#../configure --disable-multilib --enable-languages=c,c++ --enable-checking=no

# Odroid-C2 AArch64
#../configure --enable-languages=c,c++ --with-cpu=cortex-a53 --enable-checking=no

# Old Pi2
#../configure --enable-languages=c,c++ --with-cpu=cortex-a7 \
#  --with-fpu=neon-vfpv4 --with-float=hard --build=arm-linux-gnueabihf \
#  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-checking=no

#
#  Now build GCC which will take a long time.  This could range from
#  4.5 hours on a Pi3B+ up to about 50 hours on a Pi Zero.  It can be
#  left to complete overnight (or over the weekend for a Pi Zero :-)
#  The most likely causes of failure are lack of disk space, lack of
#  swap space or memory, or the wrong configure section uncommented.
#  The new compiler is placed in /usr/local/bin, the existing compiler remains 
#  in /usr/bin and may be used by giving its version gcc-6 (say).
#
if make -j `nproc`
then
  echo
  read -p "Do you wish to install the new GCC (y/n)? " yn
  case $yn in
	 [Yy]* ) sudo make install ;;
		 * ) exit ;;
  esac
fi

#
# An alternative way of adding swap
#
#sudo dd if=/dev/zero of=/swapfile1GB bs=1G count=1
#sudo chmod 0600 /swapfile1GB
#sudo mkswap /swapfile1GB
#sudo swapon /swapfile1GB

以上是关于sh 为Raspberry PI安装GCC 8.1的主要内容,如果未能解决你的问题,请参考以下文章

sh 在Raspberry PI 2上安装docker

sh 使用Raspbian在Raspberry Pi上安装mitmproxy的说明。

sh 在Raspberry Pi 3 B +上安装Intel Movidius SDK v2

sh 在Raspberry Pi上安装tmux 2.0(Debian 7.8)Raspbian Wheezy

sh 在Raspberry Pi上安装tmux 2.0(Debian 7.8)Raspbian Wheezy

sh 在Raspberry Pi上安装tmux 2.0(Debian 7.8)Raspbian Wheezy