话不多说,编译TcMalloc, jsoncpp 以及一些其他的库…
命令:
1 2 3 4 5 6 7 8 9 |
git clone https://gitee.com/tkxiong/gperftools.git cd gperftools/ ../configure --prefix=/usr/local/lib \ --disable-cpu-profiler \ --disable-heap-profiler \ --disable-heap-checker \ --disable-debugalloc \ --enable-minimal make && make install |
–prefix 就是生成路径,需要绝对地址。
如果用cmake的话:
1 2 3 |
mkdir -p release cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=./release make && make install |
这个是编译完整版,取 libtcmalloc_minimal.a 用即可.
Jsoncpp
1 2 3 4 5 6 |
git clone https://gitee.com/tkxiong/jsoncpp.git cd jsoncpp/ git checkout 1.9.4 mkdir -p release cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=./release make && make install |
-DCMAKE_INSTALL_PREFIX= 就是install路径,可以用相对地址。
我在curl用到了https 和 http2, 故需要提前编译其依赖 nghttp2 与 openssl.
nghttp2
1 2 3 4 5 6 7 8 9 10 |
git clone https://gitee.com/tkxiong/nghttp2.git cd nghttp2/ git switch v1.44.0 mkdir -p release cmake CMakeLists.txt \ -DCMAKE_INSTALL_PREFIX=./release \ -DENABLE_LIB_ONLY=ON \ -DENABLE_STATIC_LIB=ON \ -DENABLE_SHARED_LIB=OFF make && make install |
ENABLE_LIB_ONLY 只编译库
ENABLE_STATIC_LIB 编译静态库
openssl
这里本人试了1.1.11l版本,发现不行(可能是因为编译版本与系统版本不同,curl编译出问题链接到系统版本了);
1 2 3 4 5 6 7 8 |
cd Download wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1l.tar.gz cd .. tar zxvf Download/openssl-1.1.1l.tar.gz cd openssl-1.1.1l/ mkdir release ./config --prefix=/data/tkxiong/openssl-1.1.1l/release make && make install |
改为尝试1.0.2u版本。
1 2 3 4 5 6 7 8 |
cd Download wget --no-check-certificate https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz cd .. tar zxvf Download/openssl-1.0.2u.tar.gz cd openssl-1.0.2u/ mkdir release ./config --prefix=/data/tkxiong/openssl-1.0.2u/release/ no-shared make && make install |
记录: 最终发现是grpc也依赖了openssl,与 curl依赖的openssl版本冲突导致的问题。
curl 修改为使用 7.83.0 版本
下文的want_h2_path, 在7.83.0版本中为: want_nghttp2_pkg_config_path
with-openssl 后面不带地址说明使用系统openssl地址
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
wget --no-check-certificate https://curl.se/download/curl-7.83.0.tar.gz tar -zxvf curl-7.83.0.tar.gz cd curl-7.83.0 # 修改configure文件; 需要修改configure文件,才能找到nghttp2. want_h2_path="$withval/lib/pkgconfig" to want_h2_path="$withval/lib64/pkgconfig" mkdir release ./configure --prefix=/data/tkxiong/curl-7.83.0/release \ --with-nghttp2=/data/tkxiong/nghttp2/release \ --with-openssl \ --disable-shared make && make install |
git clone 编译方式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
git clone https://github.com/curl/curl.git autoreconf -fi # change configure file: want_h2_path="$withval/lib/pkgconfig" to want_h2_path="$withval/lib64/pkgconfig" # revert code. ... ... # build ./configure --prefix=/data/tkxiong/curl/release \ --with-nghttp2=/data/tkxiong/nghttp2/release \ --disable-shared \ --without-ssl make && make install |
1 |
./curl -vI -g --http2 "http://121.37.5.232:10000/hello/" |
问题还是没解决。 —— 最后是curl修复了代码.
libuv
1 2 3 4 5 6 |
git clone https://gitee.com/tkxiong/libuv.git cd libuv git checkout v1.42.0 mkdir -p release cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=./release make && make install |
openssl-1.1.1l
1 2 3 4 5 6 7 8 |
cd Download wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1l.tar.gz cd .. tar zxvf Download/openssl-1.1.1l.tar.gz cd openssl-1.1.1l/ mkdir release ./config --prefix=/data/tkxiong/openssl-1.1.1l/release no-shared make && make install |
指定 no-shared 是因为我们项目都统一使用静态库,不需要编译动态库。
zlib 1.2.11
1 2 3 4 5 6 7 8 |
cd Download/ wget --no-check-certificate https://zlib.net/zlib-1.2.11.tar.gz cd .. tar -zxvf Download/zlib-1.2.11.tar.gz cd zlib-1.2.11/ mkdir release cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=./release make && make install |
protobuf 3.14.0.0
1 2 3 4 5 6 7 8 9 10 |
git clone https://gitee.com/tkxiong/protobuf.git cd protobuf/ git switch -c v3.14.0 git submodule init vim .git/config #修改submodule地址为gitee地址 git submodule update ./autogen.sh mkdir release ./configure --prefix=/data/tkxiong/protobuf/release/ make && make install |
re2
1 2 3 4 5 |
git clone https://gitee.com/tkxiong/re2.git cd re2/ mkdir release cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=./release make && make install |
cares-1_18_1
1 2 3 4 5 6 |
git clone https://gitee.com/tkxiong/cares.git cd cares/ git switch -c cares-1_18_1 mkdir release cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=./release make && make install |
abseil-cpp 20210324.2
1 2 3 4 5 6 |
git clone https://gitee.com/tkxiong/abseil-cpp.git cd abseil-cpp/ git switch -c 20210324.2 mkdir release cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=./release make && make install |
…
【编译】TCMalloc, jsoncpp, nghttp2, openssl, curl