色碼擷取器 - Gpick安裝教學(失敗版)

官網:https://code.google.com/p/gpick/
可使用 yum 安裝,來源是EPEL,但是版本當然不是最新的。
以下是安裝最新版本的步驟。

下載gpick套件,但是格式為deb檔,因此要轉換成CentOS可以安裝的格式,轉換工具為alien

# mkdir -p /data/src
# wget https://gpick.googlecode.com/files/gpick_0.2.5-1_i386.deb
# wget http://ftp.de.debian.org/debian/pool/main/a/alien/alien_8.90.tar.gz
# tar zxf alien_8.90.tar.gz
# cd alien
# perl Makefile.PL
  Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5
  /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at Makefile.PL line 2.
  BEGIN failed--compilation aborted at Makefile.PL line 2. //缺少 ExtUtils::MakeMaker 模組,透過CPAN安裝即可。
# perl Makefile.PL
# make && make install
# yum install -y rpm-build
# cd ..

# alien -r gpick_0.2.5-1_i386.deb
  Warning: Skipping conversion of scripts in package gpick: postinst postrm
  Warning: Use the --scripts parameter to include the scripts.
  gpick-0.2.5-2.i386.rpm generated

# rpm -ivh gpick-0.2.5-2.i386.rpm
  error: Failed dependencies:
    liblua5.2.so.0 is needed by gpick-0.2.5-2.i386
    libstdc++.so.6(GLIBCXX_3.4.15) is needed by gpick-0.2.5-2.i386
註:deb轉換rpm參考文獻

安裝 liblua5.2.so.0

# wget http://mirrors.kernel.org/ubuntu/pool/main/l/lua5.2/liblua5.2-0_5.2.2-1_i386.deb
# alien -r liblua5.2-0_5.2.2-1_i386.deb
# rpm -ivh liblua5.2-0-5.2.2-2.i386.rpm

查詢 GLIBCXX 版本

# find / -name libstdc++.so.6
  /usr/lib/libstdc++.so.6
# strings /usr/lib/libstdc++.so.6 | grep GLIBCXX
  ...略
  GLIBCXX_3.4.11
  GLIBCXX_3.4.12
  GLIBCXX_3.4.13 <==很明顯沒有我們需要的版本GLIBCXX_3.4.15
  GLIBCXX_FORCE_NEW
  GLIBCXX_DEBUG_MESSAGE_LENGTH

# rpm -qf /usr/lib/libstdc++.so.6 //找尋libstdc++.so.6是哪一個套件提供的(方法2:yum whatprovides libstdc++.so.6)
  libstdc++-4.4.7-4.el6.i686

# rpm -q gcc
  gcc-4.4.7-4.el6.i686 //目前gcc版本

# rpm -q centos-release
  centos-release-6-5.el6.centos.11.1.i686 //目前作業系統版本


安裝 libstdc++.so.6(GLIBCXX_3.4.15)

# wget ftp://ftp.univie.ac.at/systems/linux/fedora/updates/20/x86_64/libstdc++-4.8.2-7.fc20.i686.rpm
# rpm -ivh libstdc++-4.8.2-7.fc20.i686.rpm
# rpm2cpio libstdc++-4.8.2-7.fc20.i686.rpm |cpio -idmv
# pwd
  /root/GLIBC/usr/lib
# ll
  lrwxrwxrwx. 1 root root 19 Mar 24 01:20 libstdc++.so.6 -> libstdc++.so.6.0.19
  -rwxr-xr-x. 1 root root 938796 Dec 12 11:26 libstdc++.so.6.0.19
# rm /usr/lib/libstdc++.so.6
# ln -s /usr/lib/libstdc++.so.6.0.19 /usr/lib/libstdc++.so.6
# strings /usr/lib/libstdc++.so.6 | grep GLIBCXX
  ...略
  GLIBCXX_3.4.14
  GLIBCXX_3.4.15
  GLIBCXX_3.4.16
  GLIBCXX_3.4.17
  GLIBCXX_3.4.18
  GLIBCXX_3.4.19
# rpm -ivh gpick-0.2.5-2.i386.rpm
  error: Failed dependencies: //還是失敗
    libstdc++.so.6(GLIBCXX_3.4.15) is needed by gpick-0.2.5-2.i386

升級GLIBC

# rpm -qi glibc | grep "Version"
  Version : 2.12   Vendor: CentOS
# wget ftp://195.220.108.108/linux/fedora/linux/development/rawhide/i386/os/Packages/g/glibc-common-2.19.90-7.fc21.i686.rpm
# wget ftp://195.220.108.108/linux/fedora/linux/development/rawhide/i386/os/Packages/g/glibc-headers-2.19.90-7.fc21.i686.rpm
# wget ftp://195.220.108.108/linux/fedora/linux/development/rawhide/i386/os/Packages/g/glibc-devel-2.19.90-7.fc21.i686.rpm
# wget ftp://195.220.108.108/linux/fedora/linux/development/rawhide/i386/os/Packages/g/glibc-2.19.90-7.fc21.
i686.rpm
# rpm -Uvh --aid --nodeps glibc-devel-2.19.90-7.fc21.i686.rpm
# rpm -Uvh --aid --nodeps glibc-headers-2.19.90-7.fc21.i686.rpm
# rpm -Uvh --aid --nodeps glibc-2.19.90-7.fc21.i686.rpm
# rpm -Uvh --aid --nodeps glibc-common-2.19.90-7.fc21.i686.rpm
# rpm -qi glibc | grep "Version"
  Version : 2.19.90   Vendor: Fedora Project
# rpm -ivh gpick-0.2.5-2.i386.rpm
  error: Failed dependencies: //還是失敗
    libstdc++.so.6(GLIBCXX_3.4.15) is needed by gpick-0.2.5-2.i386

我想是我目前的功力還不夠解決"libstdc++.so.6(GLIBCXX_3.4.15) is needed by gpick-0.2.5-2.i386"這個問題,以後有時間再來奮戰吧!


升級GCC之困難重重版

升級GCC步驟:gmp->mpfr->mpc->GCC
環境 VM:VMware Player 5.0
OS:CentOS(6.5 2.6.32-431.el6.i686)
GCC:4.4.7 --> 4.8.2

GCC載點:ftp://gnu.mirror.iweb.com/gcc/
gmp官網:http://gmplib.org/
mpfr官網:http://www.mpfr.org/
mpc載點:ftp://ftp.gnu.org/gnu/mpc/

安裝gmp、mpfr、mpc

# wget https://gmplib.org/download/gmp/gmp-5.1.3.tar.lz
# tar xf gmp-5.1.3.tar.lz
# yum install -y lzip
# cd /data/src/gmp-5.1.3
# ./configure --prefix=/data/src/gmp-5.1.3
# make -j && make check && make install

# wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.gz
# tar zxf mpfr-3.1.2.tar.gz
# cd /data/src/mpfr-3.1.2
# ./configure --prefix=/data/src/mpfr-3.1.2 --with-gmp=/data/src/gmp-5.1.3
# make -j && make check && make install

# wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz
# tar zxf mpc-1.0.2.tar.gz
# cd mpc-1.0.2
# ./configure --prefix=/data/src/mpc-1.0.2 --with-mpfr=/data/src/mpfr-3.1.2 --with-gmp=/data/src/gmp-5.1.3
# make -j && make check && make install

# vim /etc/ld.so.conf
  /data/src/gmp-5.1.3/lib
  /data/src/mpfr-3.1.2/lib
  /data/src/mpc-1.0.2/lib
# ldconfig

//環境變數LD_LIBRARY_PATH及LD_RUN_PATH設定,避免GCC編譯時發生錯誤。
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/src/mpc-1.0.2/lib:/data/src/mpc-1.0.2/lib:/data/src/mpc-1.0.2/lib
# export LD_RUN_PATH=$LD_LIBRARY_PATH:/data/src/mpc-1.0.2/lib:/data/src/mpc-1.0.2/lib:/data/src/mpc-1.0.2/lib

安裝GCC # yum install -y gcc-c++
# curl -R -O ftp://gnu.mirror.iweb.com/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz
# mkdir build_gcc482
# cd build_gcc482
# ../gcc-4.8.2/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/data/src/gmp-5.1.3 --with-mpfr=/data/src/mpfr-3.1.2 --with-mpc=/data/src/mpc-1.0.1
  ...略
  checking for the correct version of gmp.h... yes
  checking for the correct version of mpfr.h... yes
  checking for the correct version of mpc.h... no
  configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
  //找不到mpc.h的錯誤訊息,原來是我路徑打錯了。

  Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
  their locations. Source code for these libraries can be found at
  their respective hosting sites as well as at
  ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also
  http://gcc.gnu.org/install/prerequisites.html for additional info. If
  you obtained GMP, MPFR and/or MPC from a vendor distribution package,
  make sure that you have installed both the libraries and the header
  files. They may be located in separate packages.
# ../gcc-4.8.2/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/data/src/gmp-5.1.3 --with-mpfr=/data/src/mpfr-3.1.2 --with-mpc=/data/src/mpc-1.0.2
# make && make install
# gcc --version   gcc (GCC) 4.8.2
  Copyright (C) 2013 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions. There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

測試

# vim helloworld.c
  #include
  int main(void){
  printf("hello world. \n");
  return 0;
  }
# gcc helloworld.c
# ls
  a.out helloworld.c
# ./a.out
  hello world.