Redhat Linux 升级GCC和boost

46 篇文章 1 订阅

 

因为工作需要在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.)” 

MPC下载地址:https://github.com/DOCGroup/MPC

QuickFast下载地址:https://github.com/objectcomputing/quickfast

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头文件。

 

安装clang-format:

clang-format是LVVM中的一个工具,用来格式化代码。

LLVM名字源自于底层虚拟机(Low Level Virtual Machine)的缩写,由于命名带来的混乱,目前LLVM就是该项目的全称。LLVM 核心库提供了编译器相关的支持,可以作为多种语言编译器的后台来使用。能够进行程序语言的编译期优化、链接优化、在线编译优化、代码生成等。

Clang是LLVM项目的一个子项目,它是基于LLVM架构的一个C/C++/Objective-C编译器前端。

为了安装使用clang-format,我们需要安装整个LLVM和Clang。LLVM从某个新版本起只支持使用CMAKE编译了。所以下面的安装是使用CMAKE进行的。

 

下载LLVM Sourcecode http://releases.llvm.org/8.0.0/llvm-8.0.0.src.tar.xz

下载Clang Sourcecode http://releases.llvm.org/8.0.0/cfe-8.0.0.src.tar.xz

tar -xJvf llvm-8.0.0.src.tar.xz
tar -xJvf cfe-8.0.0.src.tar.xz
cp -r cfe-8.0.0 llvm-8.0.0/tools/
cd llvm-8.0.0 
mkdir mybuilddir
cd mybuilddir
cmake ../
cmake --build .
cmake -DCMAKE_INSTALL_PREFIX=/home/wqf/usr/lib/llvm_8.0.0 -P cmake_install.cmake

PATH中加上PATH=/home/wqf/usr/lib/llvm_8.0.0/bin, LIBRARY_PATH和LD_LIBRARY_PATH中加上/home/wqf/usr/lib/llvm_8.0.0/lib, C_INCLUDE_PATH和CPLUS_INCLUDE_PATH中加上/home/wqf/usr/lib/llvm_8.0.0/include,之后就可以运行clang-format了。

clang-format async_tcp_echo_server.cpp -style=Google -i

指导网页:http://llvm.org/docs/CMake.html

VIM插件设置:http://clang.llvm.org/docs/ClangFormat.html

function! Formatonsave()
  let l:formatdiff = 1
  pyf ~/llvm/tools/clang/tools/clang-format/clang-format.py
endfunction
autocmd BufWritePre *.h,*.cc,*.cpp call Formatonsave()

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值