1. 程式人生 > >Redhat Linux 升級GCC和boost

Redhat Linux 升級GCC和boost

因為工作需要在linux上安裝Thrift,在官網http://thrift.apache.org/developers上查到了如下依賴:

Basic requirements
A relatively POSIX-compliant *NIX system
Cygwin or MinGW can be used on Windows (but there are better options, see below)
g++ 4.2 (4.8 or later required for thrift compiler plug-in support)
boost 1.53.0
Runtime libraries for lex and yacc might be needed for the compiler.
Requirements for building from source
GNU build tools: autoconf 2.65 automake 1.13 libtool 1.5.24 pkg-config autoconf macros (pkg.m4) lex and yacc (developed primarily with flex and bison) libssl-dev
A relatively POSIX-compliant *NIX system Cygwin or MinGW can be used on Windows (but there are better options, see below) g++ 4.2 (4.8 or later required for thrift compiler plug-in support) boost 1.53.0 Runtime libraries for lex and yacc might be needed for the compiler. Requirements for building from source
GNU build tools: autoconf 2.65 automake 1.13 libtool 1.5.24 pkg-config autoconf macros (pkg.m4) lex and yacc (developed primarily with flex and bison) libssl-dev

檢視當前系統的boost版本如下為比較老的1.41版本,於是決定將其升級到最新的1.67。

$ grep BOOST_LIB_VERSION /usr/include/boost/version.hpp
//  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_41"

截止到今天(20180620),GCC的最新版本,2018年5月份釋出的GCC8.1,但是Boost1.67最新的測試過的GCC版本為7.3.0,所以決定升級GCC到7.3.0比較保險。

下載gcc-7.3.0.tar.gz (http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-7.3.0/)

使用WinSCP從Windows上傳到Linux後解壓:tar -xvf gcc-7.3.0.tar.gz

檢視gcc-7.3.0/contrib/download_prerequisites檔案可以看到gcc7.3.0的依賴如下:

gmp='gmp-6.1.0.tar.bz2'
mpfr='mpfr-3.1.4.tar.bz2'
mpc='mpc-1.0.3.tar.gz'
isl='isl-0.16.1.tar.bz2'

gmp官網https://gmplib.org/#DOWNLOAD好像只提供最新版的gmp下載,只好下載了此時最新版gmp-6.1.2.tar.bz2,希望能夠和6.1.0一樣與GCC7.3.0工作。將下載到了gmp上傳到linux,然後解壓:tar -xjf gmp-6.1.2.tar.bz2, 然後執行如下命令安裝。注意因為這裡用的是非root賬戶,故指定prefix要安裝在自己目錄下。

./configure --prefix=/home/wqf/usr/lib/gmp-6.1.2/ && make && make install

安裝結果如下:

----------------------------------------------------------------------
Libraries have been installed in:
   /home/wqf/usr/lib/gmp-6.1.2/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

MPFR官網https://www.mpfr.org/mpfr-3.1.4/ 下載mpfr-3.1.4.tar.bz2,從windows上傳到linux後解壓:tar -xjf  mpfr-3.1.4.tar.bz2,然後執行下面命令安裝:

./configure --prefix=/home/wqf/usr/lib/mpfr_3.1.4/ --with-gmp=/home/wqf/usr/lib/gmp-6.1.2/  && make && make install

安裝結果如下:

----------------------------------------------------------------------
Libraries have been installed in:
   /home/wqf/usr/lib/mpfr_3.1.4/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

MPC官網http://ftp.gnu.org/gnu/mpc/ 下載 mpc-1.0.3.tar.gz,從windows上傳到linux後解壓:tar -xvf  mpc-1.0.3.tar.gz,然後執行下面命令安裝:

./configure --prefix=/home/wqf/usr/lib/mpc_1.0.3/ --with-gmp=/home/wqf/usr/lib/gmp-6.1.2/ --with-mpfr=/home/wqf/usr/lib/mpfr_3.1.4/ && make && make install

安裝結果如下:

----------------------------------------------------------------------
Libraries have been installed in:
   /home/wqf/usr/lib/mpc_1.0.3/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

安裝GCC7.3.0

./configure --prefix=/home/wqf/usr/lib/gcc_7.3.0/ --enable-threads=posix --disable-checking --enable-language=c,c++ --with-gmp=/home/wqf/usr/lib/gmp-6.1.2/ --with-mpfr=/home/wqf/usr/lib/mpfr_3.1.4/ --with-mpc=/home/wqf/usr/lib/mpc_1.0.3/

結果出錯如下:

/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
configure: error: I suspect your system does not have 32-bit development libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.

錯誤原因大概是因為64位系統沒有32位的lib和header,因為目前我也不需要編譯32位的東西,所以就直接用disable-multilib選項了。

./configure --prefix=/home/wqf/usr/lib/gcc_7.3.0/ --enable-threads=posix --disable-checking --enable-language=c,c++ --with-gmp=/home/wqf/usr/lib/gmp-6.1.2/ --with-mpfr=/home/wqf/usr/lib/mpfr_3.1.4/ --with-mpc=/home/wqf/usr/lib/mpc_1.0.3/ --disable-multilib &&make && make install

結果再make時又出現了錯誤如下:

/home/wqf/download/gcc-7.3.0/host-x86_64-pc-linux-gnu/gcc/cc1: error while loading shared libraries: libmpc.so.3: cannot open shared object file: No such file or directory

通過查詢發現這個檔案在我的安裝mpc目錄下其實是有的:

[wqf@admin lib]$ pwd
/home/wqf/usr/lib/mpc_1.0.3/lib
[wqf@admin lib]$ ls -l
total 348
-rw-r--r-- 1 wqf wqf 239220 Jun 20 17:56 libmpc.a
-rwxr-xr-x 1 wqf wqf   1129 Jun 20 17:56 libmpc.la
lrwxrwxrwx 1 wqf wqf     15 Jun 20 17:56 libmpc.so -> libmpc.so.3.0.0
lrwxrwxrwx 1 wqf wqf     15 Jun 20 17:56 libmpc.so.3 -> libmpc.so.3.0.0
-rwxr-xr-x 1 wqf wqf 108163 Jun 20 17:56 libmpc.so.3.0.0lrwxrwxrwx 1 wqf wqf     15 Jun 20 17:56 libmpc.so.3 -> libmpc.so.3.0.0
-rwxr-xr-x 1 wqf wqf 108163 Jun 20 17:56 libmpc.so.3.0.0

這時想到應該是環境變數需要設定,開啟檔案~/.bash_profile,加入如下內容:

LD_LIBRARY_PATH=$HOME/usr/lib/gmp-6.1.2/lib:$HOME/usr/lib/mpfr_3.1.4/lib:$HOME/usr/lib/mpc_1.0.3/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

這樣再make時就好了。

GCC安裝結果如下:

----------------------------------------------------------------------
Libraries have been installed in:
   /home/wqf/usr/lib/gcc_7.3.0/lib/../lib64

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

安裝之後,要記得更新環境變數PATH,在~/.bash_profile中如下:

PATH=$HOME/usr/lib/gcc_7.3.0/bin:$HOME/usr/lib/gcc_7.3.0/lib64:$PATH:$HOME/bin

export這個Path之後,在檢視GCC版本,就會看到GCC用到了新安裝的版本了。

官網https://www.boost.org/users/history/version_1_67_0.html下載boost_1_67_0.tar.bz2,從windows上傳到linux後解壓:tar -xjf boost_1_67_0.tar.bz2

./bootstrap.sh
./b2
./b2 --prefix=/home/wqf/usr/lib/boost_1_67_0 install 

然後還是要更新~/.bash_profile檔案,內容如下:

PATH=$HOME/usr/lib/gcc_7.3.0/bin:$HOME/usr/lib/gcc_7.3.0/lib64:$PATH:$HOME/bin
LD_LIBRARY_PATH=$HOME/usr/lib/boost_1_67_0/lib:$HOME/usr/lib/gcc_7.3.0/lib:$HOME/usr/lib/gcc_7.3.0/lib64:$HOME/usr/lib/gmp-6.1.2/lib:$HOME/usr/lib/mpfr_3.1.4/lib:$HOME/usr/lib/mpc_1.0.3/lib:$LD_LIBRARY_PATH

export PATH
export LD_LIBRARY_PATH

接下來安裝Thrift,下面是官網上顯示的依賴包:

Basic requirements
A relatively POSIX-compliant *NIX system
Cygwin or MinGW can be used on Windows (but there are better options, see below)
g++ 4.2 (4.8 or later required for thrift compiler plug-in support)
boost 1.53.0
Runtime libraries for lex and yacc might be needed for the compiler.
Requirements for building from source
GNU build tools:
autoconf 2.65
automake 1.13
libtool 1.5.24
pkg-config autoconf macros (pkg.m4)
lex and yacc (developed primarily with flex and bison)
libssl-dev

Language requirements
These are only required if you choose to build the libraries for the given language

C++
Boost 1.53.0
libevent (optional, to build the nonblocking server)
zlib (optional)
Python 2.6 (including header files for extension modules)
A relatively POSIX-compliant *NIX system
Cygwin or MinGW can be used on Windows (but there are better options, see below)
g++ 4.2 (4.8 or later required for thrift compiler plug-in support)
boost 1.53.0
Runtime libraries for lex and yacc might be needed for the compiler.
Requirements for building from source
GNU build tools:
autoconf 2.65
automake 1.13
libtool 1.5.24
pkg-config autoconf macros (pkg.m4)
lex and yacc (developed primarily with flex and bison)
libssl-dev

Language requirements
These are only required if you choose to build the libraries for the given language

C++
Boost 1.53.0
libevent (optional, to build the nonblocking server)
zlib (optional)
Python 2.6 (including header files for extension modules)

目前已安裝版本如下:

$ autoconf --version
autoconf (GNU Autoconf) 2.63

$ automake --version
automake (GNU automake) 1.11.1

$ libtool --version
ltmain.sh (GNU libtool) 2.2.6b

$  pkg-config  --version
0.23

$ yacc -V
yacc - 1.9 20070509

$ lex -V
lex 2.5.35

$ python --version
Python 2.6.6

所以需要安裝或升級的有:autoconf, automake, openssl, libevent,命令如下:

tar -xjf  autoconf-2.65.tar.bz2
cd autoconf-2.65
 ./configure --prefix=/home/wqf/usr/lib/autoconf_2.65
make 
make install
#執行下面並把/usr/lib/autoconf_2.65/bin加入 ~/.bash_profile的PATH
export PATH=$HOME/usr/lib/autoconf_2.65/bin:$PATH


tar -xzvf  automake-1.13.tar.gz
cd automake-1.13
 ./configure --prefix=/home/wqf/usr/lib/automake_1.13
make 
make install
#執行下面並把/usr/lib/automake_1.13/bin加入 ~/.bash_profile的PATH
export PATH=$HOME/usr/lib/automake_1.13/bin:$PATH


#libssl-dev is the Debian name for the OpenSSL development libraries.
#On the RHEL side, it's called openssl-devel.
tar -xzvf openssl-1.1.0h.tar.gz
cd openssl-1.1.0h
./config --prefix=/home/wqf/usr/lib/openssl_1.1.0h
make 
make install
#把下面加入PATH和LD_LIBRARY_PATH
$HOME/usr/lib/openssl_1.1.0h/bin
$HOME/usr/lib/openssl_1.1.0h/lib


tar -xzvf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=/home/wqf/usr/lib/libevent_2.1.8
make 
make install
#把下面加入PATH和LD_LIBRARY_PATH
$HOME/usr/lib/libevent_2.1.8/bin
$HOME/usr/lib/libevent_2.1.8/lib


安裝Thrift命令如下:

tar -xzvf thrift-0.11.0.tar.gz
cd thrift-0.11.0
./configure --prefix=/home/wqf/usr/lib/thrift_0.11.0
make 
make install

執行configure時出錯,

checking for bison version >= 2.5... no
configure: error: Bison version 2.5 or higher must be installed on the system!

需要升級bison版本,Bison升級過程如下:

tar -xzvf bison-3.0.5.tar.gz
cd bison-3.0.5
./configure --prefix=/home/wqf/usr/lib/bison_3.0.5
make 
make install
$HOME/usr/lib/bison_3.0.5/bin
$HOME/usr/lib/bison_3.0.5/lib

升級完後繼續執行Thriftdeconfig就成功了。結果如下:

thrift 0.11.0

Building C (GLib) Library .... : yes
Building C# (Mono) Library ... : no
Building C++ Library ......... : no
Building D Library ........... : no
Building Dart Library ........ : no
Building dotnetcore Library .. : no
Building Erlang Library ...... : no
Building Go Library .......... : no
Building Haskell Library ..... : no
Building Haxe Library ........ : no
Building Java Library ........ : yes
Building Lua Library ......... : no
Building NodeJS Library ...... : no
Building Perl Library ........ : no
Building PHP Library ......... : no
Building Plugin Support ...... : no
Building Python Library ...... : yes
Building Py3 Library ......... : no
Building Ruby Library ........ : no
Building Rust Library ........ : no

Java Library:
   Using ant ................. : /usr/bin/ant
   Using java ................ : java
   Using javac ............... : javac
   Using ant version ......... : Apache Ant version 1.7.1 compiled on April 26 2010
   Using java version ........ : java version "1.7.0_79"

Python Library:
   Using Python .............. : /usr/bin/python
   Using Python version ...... : Python 2.6.6

If something is missing that you think should be present,
please skim the output of configure to find the missing
component.  Details are present in config.log.

但是執行make時又有錯誤了:

Making all in java
make[3]: Entering directory `/home/wqf/download/thrift-0.11.0/lib/java'
/usr/bin/ant
Buildfile: build.xml

setup.init:
    [mkdir] Created dir: /home/wqf/download/thrift-0.11.0/lib/java/build
    [mkdir] Created dir: /home/wqf/download/thrift-0.11.0/lib/java/build/lib
    [mkdir] Created dir: /home/wqf/download/thrift-0.11.0/lib/java/build/tools
    [mkdir] Created dir: /home/wqf/download/thrift-0.11.0/lib/java/build/test

mvn.ant.tasks.check:

proxy:

mvn.ant.tasks.download:
      [get] Getting: http://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar
      [get] To: /home/wqf/download/thrift-0.11.0/lib/java/build/tools/maven-ant-tasks-2.1.3.jar
      [get] Error getting http://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar to /home/wqf/download/thrift-0.11.0/lib/java/build/tools/maven-ant-tasks-2.1.3.jar

BUILD FAILED
java.net.UnknownHostException: repo1.maven.org
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
        at sun.net.www.http.HttpClient.New(HttpClient.java:308)
        at sun.net.www.http.HttpClient.New(HttpClient.java:326)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:997)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:933)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:851)
        at org.apache.tools.ant.taskdefs.Get.doGet(Get.java:145)
        at org.apache.tools.ant.taskdefs.Get.execute(Get.java:78)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
        at org.apache.tools.ant.Main.runBuild(Main.java:758)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

Total time: 0 seconds
make[3]: *** [all-local] Error 1
make[3]: Leaving directory `/home/wqf/download/thrift-0.11.0/lib/java'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wqf/download/thrift-0.11.0/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wqf/download/thrift-0.11.0'
make: *** [all] Error 2

可以看出錯誤出現在安裝java有關的東西時,因為我並不需要java,所以準備重新執行configure去掉有關java的thrift安裝。

繼續執行會有如下錯誤:

/bin/sh ../../libtool  --tag=CC   --mode=link gcc -g -Wall -Wextra -pedantic -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include     -g -O2 -lssl -lcrypto   -L/home/wqf/usr/lib/openssl_1.1.0h/lib -o tutorial_server c_glib_server.o libtutorialgencglib.la ../../lib/c_glib/libthrift_c_glib.la -lrt -lpthread
libtool: link: gcc -g -Wall -Wextra -pedantic -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -g -O2 -o .libs/tutorial_server c_glib_server.o  -L/home/wqf/usr/lib/openssl_1.1.0h/lib ./.libs/libtutorialgencglib.a /home/wqf/download/thrift-0.11.0/lib/c_glib/.libs/libthrift_c_glib.so -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lssl -lcrypto ../../lib/c_glib/.libs/libthrift_c_glib.so -lrt -lpthread -pthread -Wl,-rpath -Wl,/home/wqf/usr/lib/thrift_0.11.0/lib
/home/wqf/download/thrift-0.11.0/lib/c_glib/.libs/libthrift_c_glib.so: undefined reference to `g_info'
collect2: error: ld returned 1 exit status
make[4]: *** [tutorial_server] Error 1
make[4]: Leaving directory `/home/wqf/download/thrift-0.11.0/tutorial/c_glib'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/wqf/download/thrift-0.11.0/tutorial/c_glib'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wqf/download/thrift-0.11.0/tutorial'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wqf/download/thrift-0.11.0'
make: *** [all] Error 2

由於g_info是在glib中定義的,所以需要安裝glib。

按照如下步驟安裝glib,然而報錯說是缺少libffi,故要先安裝libffi。

tar -xvf glib-2.54.3.tar.xz
./configure --prefix=/home/wqf/usr/lib/glib_2.54.3
make
make install
checking for LIBFFI... no
configure: error: Package requirements (libffi >= 3.0.0) were not met:

No package 'libffi' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBFFI_CFLAGS
and LIBFFI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

按下面步驟安裝libffi,然後加入各種PATH中。

tar -xvf libffi-3.2.1.tar.gz
cd libffi-3.2.1
./configure --prefix=/home/wqf/usr/lib/libffi_3.2.1
make
make install

然後繼續安裝glib,又遇到了報錯,分別是libmount和libpcre。這裡安裝libpcre,但是libmount比較不好找, 就不安裝了,而是使用glib configure的--enable-libmount=no選項跳過libmount。

安裝libpcre的步驟:

tar -xjf pcre-8.42.tar.bz2
cd pcre-8.42
#注意這裡需要--enable-utf --enable-unicode-properties 是因為glib的安裝要求pcre支援utf和unicode
#不帶這兩個選項的話接下來安裝glib會報錯
./configure  --enable-utf --enable-unicode-properties --prefix=/home/wqf/usr/lib/pcre_8.42 
make
make install

安裝glib如下成功:

tar -xvf glib-2.54.3.tar.xz
cd glib-2.54.3
./configure  --enable-libmount=no --prefix=/home/wqf/usr/lib/glib_2.54.3
make
make install

接下來繼續安裝thrift:

./configure LDFLAGS="-L$HOME/usr/lib/openssl_1.1.0h/lib -L$HOME/usr/lib/glib_2.54.3/lib" --with-boost-libdir="$HOME/usr/lib/boost_1_67_0/lib" --prefix=/home/wqf/usr/lib/thrift_0.11.0 --with-java=no
make && make install

make終於成功,在make install時出現了一個小錯誤,當前user在/usr/lib/python2.7無寫許可權,給予許可權之後就成功了。

安裝glog和gflags:

#glog
tar -xzvf glog-0.3.5.tar.gz
cd glog-0.3.5
./configure --prefix=/home/wqf/usr/lib/glog_0.3.5
make
make install

#gflags
#安裝靜態庫:
tar -xzvf gflags-2.2.1.tar.gz
cd gflags-2.2.1
mkdir build && cd build
cmake ..
cp -r lib /home/wqf/usr/lib/gflags_2.2.1/
cp -r include /home/wqf/usr/lib/gflags_2.2.1/

#安裝動態庫:
cmake -DCMAKE_INSTALL_PREFIX=/home/wqf/usr/lib/gflags_2.2.1/ -DBUILD_SHARED_LIBS=ON -DGFLAGS_NAMESPACE=google -G"Unix Makefiles" .
make
make install

安裝xerces:同時安裝靜態庫和動態庫

tar -xjf  xerces-c-3.2.1.tar.bz2
cd xerces-c-3.2.1
./configure --prefix=/home/wqf/usr/lib/xerces_3.2.1 --enable-static
make
make install

安裝libpcap

tar -xzvf libpcap-1.9.0.tar.gz
cd libpcap-1.9.0
./configure --prefix=/home/wqf/usr/lib/libpcap_1.9.0 
make
make install

安裝log4cplus

tar -xjf log4cplus-1.2.1.tar.bz2
cd log4cplus-1.2.1
./configure --prefix=/home/wqf/usr/lib/log4cplus_1.2.1 --enable-static
make
make install

安裝quickfast:

根據官網github上的文件https://github.com/objectcomputing/quickfast/wiki/GettingStarted, 需要先安裝MPC。注意這裡的MPC不是平時說的Linux上的那個GNU MPC。GNU MPC是multiprecision的縮寫,是一個“C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of the result”。 而我們這裡需要安裝的MPC是“The Makefile, Project and Workspace Creator.” 的縮寫,是用來“be used to generate tool specific input (i.e., Makefile, dsp, vcproj, etc.)” 

Move to the directory where you checked out QuickFAST

cd .../QuickFAST

edit the setup.sh file
Correct exports in the file for
MPC_ROOT
BOOST_ROOT
BOOST_VERSION (should look like boost_1_NN)
BOOST_CFG (should look like gccXX_mt)
XERCES_ROOT
XERCES_LIBNAME
for non-standard installations these exports may also need to be set:
BOOST_ROOT_LIB
XERCES_LIBPATH
XERCES_INCLUDE
* Source the setup.sh file to incorporate variables into your environment:
>. ./setup.sh 
* Run MPC to generate Makefiles using the m.sh script: 
> ./m.sh 
* Make the project: 
> make

執行Make時出錯:

In file included from /home/wqf/usr/lib/boost_1_67_0/include/boost/asio.hpp:69:0,
                 from ./Communication/AsioService.h:16,
                 from ./Communication/AsynchReceiver.h:14,
                 from ./Communication/MulticastReceiver.h:13,
                 from Application/DecoderConnection.cpp:17:
/home/wqf/usr/lib/boost_1_67_0/include/boost/asio/io_service.hpp:27:20: error: conflicting declaration ‘typedef class boost::asio::io_context boost::asio::io_service’
 typedef io_context io_service;
                    ^~~~~~~~~~
In file included from Application/DecoderConnection.h:19:0,
                 from Application/DecoderConnection.cpp:6:
./Communication/AsioService_fwd.h:20:11: note: previous declaration as ‘class boost::asio::io_service’
     class io_service;
           ^~~~~~~~~~

這是由於io_service是boost::asio中定義的,不知道為什麼在quickfast程式碼中也聲明瞭。我的解決方法是在quickfast程式碼Communication/AsioService_fwd.h中註釋到這個io::service宣告,並且在Communication/AsioService_fwd.h檔案中包含boost標頭檔案。