如果是刚安装好的操作系统 先安装源里的gcc cmake make 等
apt-get install gcc g++ make cmake autoconf automake libtool
1.gcc 4.8.2
(1)上传gcc
源码在source/下
把gcc-4.8.2.tar.gz放在/home/download/
cd /home/download/
tar -xzvf gcc-4.8.2.tar.gz
cd gcc-4.8.2
(2)安装依赖项
./contrib/download_prerequisites
(3)编译安装
mkdir build
cd build
…/configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
make -j8
make install
*某些高版本gcc编译低版本gcc时,会报错
cfns.gperf:101:1: error
根据
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ec1cc0263f156f70693a62cf17b254a0029f4852
按内容修改对应源码
./md-unwind-support.h:65:47: 错误
找到 md-unwind-support.h line 61
-struct ucontext *uc_ = context->cfa;
+struct ucontext_t *uc_ = context->cfa;
还可能出现的问题以及解决方案:
问题一:(不一定出现)
解决:
cd ./x86_64-unknown-linux-gnu/libstdc+±v3/src/.libs/
rm -rf libstdc++.so.6
ln -snf /usr/lib64/libstdc++.so.6 ./libstdc++.so.6
问题二:
解决:在asan_linux.cc中添加头文件#include <signal.h> 即可
问题三:
解决:将第一行代码修改为第二行即可
__res_state statp = (__res_state)state;
struct __res_state statp = (struct __res_state)state;
问题二和问题三解决:https://blog.csdn.net/weixin_45617478/article/details/103381461
2.zlib 1.2.3
(1)上传zlib
源码在source/下
把zlib-1.2.3.tar.gz放在/home/download/
cd /home/download/
tar -xzvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
(2)编译安装
./configure
*基于openssl需要加上额外的编译参数
vim Makefile
在CFLAGS= … 后加入 -fPIC
保持退出
make & make install
3.openssl 1.0.1t
(1)上传openssl
源码在source/下
把openssl-1.0.1t.tar.gz放在/home/download/
cd /home/download/
tar -xzvf openssl-1.0.1t.tar.gz
cd openssl-1.0.1t
(2)编译安装
./config shared zlib
make depend
make & make install
(3)头文件包含
如果发现头文件被安装在诸如/usr/local/ssl/include/openssl/…之类的地方,用软连接等方式放到/usr/local/include
ln -s /usr/local/ssl/include/openssl /usr/local/include/openssl
4.Ace 6.1.0
ace库的编译安装参考:
https://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/ACE-INSTALL.html#unix
(1)上传ace
源码在source/下
把ACE+TAO+CIAO-6.1.0.tar.gz放在/home/download/
tar -xzvf ACE+TAO+CIAO-6.1.0.tar.gz
cd ACE_wrappers
(2)设置(在root下)
export ACE_ROOT=/home/download/ACE_wrappers
export LD_LIBRARY_PATH=
A
C
E
R
O
O
T
/
l
i
b
:
ACE_ROOT/lib:
ACEROOT/lib:LD_LIBRARY_PATH
注意:使用echo $ACE_ROOT命令查看是否设置成功,若设置不成功则无法make
创建$ACE_ROOT/ace/config.h
加入#include “ace/config-linux.h”
保存退出
创建$ACE_ROOT/include/makeinclude/platform_macros.GNU
加入include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
INSTALL_PREFIX = /usr/local
保存退出
在$ACE_ROOT下
make
make install
可能会出现一下问题:
error: conflicting declaration ‘typedef struct cpu_set_t cpu_set_t’
/usr/include/x86_64-linux-gnu/bits/cpu-set.h:42:3: error: ‘cpu_set_t’ has a previous declaration as ‘typedef struct cpu_set_t cpu_set_t’
解决方案:
在/ace/config.h中加入
#ifndef __cpu_set_t_defined
#define __cpu_set_t_defined
#endif //!__cpu_set_t_defined
5.Mysql 5.7
(1)sudo apt-get update
(2)sudo apt install mysql-server-5.7
(3)mysql -V
设置mysql的root用户密码
mysql -uroot
use mysql;
update user set authentication_string=password(‘123456’) where user=’root’;
flush privileges;
安装客户端
sudo apt-get install libmysqlclient-dev
6.boost 1.55
(1)上传
boost_1_55_0.tar.gz在source/下
把boost_1_55_0.tar.gz放在/home/download/
tar -xzvf boost_1_55_0.tar.gz
cd boost_1_55_0
(2)编译安装
./bootstrap.sh --with-libraries=all --with-toolset=gcc
./b2 install
可能出现…failed updating 58 targets…(是否影响)
7.protobuf2.6.1
(1)上传
protobuf-2.6.1.tar.gz在source/下
把protobuf-2.6.1.tar.gz放在/home/download/
tar -xzvf protobuf-2.6.1.tar.gz
cd protobuf-2.6.1
(2)编译安装
./configure --prefix=/usr/local/protobuf
make -j8
make check
make install
(3)配置环境
sudo vim /etc/profile
添加
export PATH=$PATH:/usr/local/protobuf/bin/
export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/
保存执行
source /etc/profile
配置动态链接库路径
vim /etc/ld.so.conf 插入: include /usr/local/protobuf/lib
ldconfig
(4)查看版本
protoc --version
8.libunwind 0.99beta(for gperftools)
(1)上传
libunwind-0.99-beta.tar.gz在source/下
把libunwind-0.99-beta.tar.gz放到/home/download/
tar -xzvf libunwind-0.99-beta.tar.gz
cd libunwind-0.99-beta
(2)编译安装
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install
可能会出现问题:…/include/dwarf.h:318:5: error: unknown type name ‘pthread_mutex_t’
解决:在/home/download/libunwind-0.99-beta/include/dwarf.h添加#include <pthread.h>
9.gperftools-1.9.1 (libtcmalloc)
(1)上传
gperftools-1.9.1.tar.gz在source/下
把gperftools-1.9.1.tar.gz放到/home/download/
tar -xzvf gperftools-1.9.1.tar.gz
cd gperftools
(2)编译安装
./configure
make && make install
可能有编译错误
修改src/base/linuxthreads.cc line196
–static void SignalHandler(int signum, siginfo_t *si, void *data)
++static void SignalHandler(int signum, siginfo *si, void *data)
10.Libcurl 7.40
(1)上传
curl-7.40.0.tar.gz在source/下
把curl-7.40.0.tar.gz放到/home/download/
tar -xzvf curl-7.40.0.tar.gz
cd curl-7.40.0
(2)编译安装
./configure --without-nss -with-ssl=/usr/local/ssl
*注意之前安装openssl的位置
autoreconf -ivf
make && make install
可能出现的问题:
ll /usr/local/lib/libcurl.so.4
rm -r /usr/local/lib/libcurl.so.4
ln -s /usr/lib/x86_64-linux-gnu/libcurl.so.4.5.0 /usr/local/lib/libcurl.so.4
11.Scons
把scons-2.1.0-1.noarch.rpm放到/home/download/
rpm -Uvh scons-2.1.0-1.noarch.rpm
或者直接命令安装
apt install scons
12.libjson_linux
(1)上传
jsoncpp-src-0.5.0.tar.gz在source/下
把jsoncpp-src-0.5.0.tar.gz放到/home/download/
tar -xzvf jsoncpp-src-0.5.0.tar.gz
cd jsoncpp-src-0.5.0
(2)安装
scons platform=linux-gcc
cp /home/download/jsoncpp-src-0.5.0/libs/linux-gcc-4.8.2/* /usr/local/lib/
ln -s /usr/local/lib/libjson_linux-gcc-4.8.2_libmt.so /usr/local/lib/libjson_linux.so
cp -r /home/download/jsoncpp-src-0.5.0/include/json /usr/local/include/
13、libbson-1.0.0
tar -zxvf libbson-1.0.0.tar.gz
cd libbson-1.0.0
mkdir cmake_build
cd cmake_build
cmake -fPIC … -DCMAKE_BUILD_TYPE=Release
make
make install
14、mongo-c-driver
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.0.0/mongo-c-driver-1.0.0.tar.gz
tar -xzf mongo-c-driver-1.0.0.tar.gz
cd mongo-c-driver-1.0.0/
./configure
make
make install
15、redis
redis-2.8.4.tar.gz在source/下
tar -zxvf redis-2.8.4.tar.gz
cd redis-2.8.4
Make
make可能出现问题: error: …/deps/jemalloc/lib/libjemalloc.a:,加上参数重新编译
make MALLOC=libc
make PREFIX=/usr/local/redis install
cp ./redis.conf /usr/local/redis/bin/
cd /usr/local/redis/bin
vim redis.conf
#requirepass foobared去掉注释,foobared改为自己的密码,我在这里改为
requirepass redis@ime
daemonize no 改为yes
保存退出
启动redis
./redis-server redis.conf
16、hiredis-0.13.3
hiredis-0.13.3.tar.gz在source/下
把hiredis-0.13.3.tar.gz放到/home/download/
tar -xzvf hiredis-0.13.3.tar.gz
cd hiredis-0.13.3
make
make install