话不多说,编译CMake, TcMalloc, jsoncpp 以及一些其他的库…
【编译】CMake, TCMalloc, jsoncpp, nghttp2, openssl, curl
CMake 版本3.21.1
|
|
sudo yum install –y gcc gcc–c++ make openssl–devel
|
其实C++编译版本我们一般用 devtoolset-10,但是也无所谓。
下载CMake源码:
|
|
wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1.tar.gz
|
编译:
|
|
tar –zxvf cmake–3.21.1.tar.gz
cd cmake–3.21.1
./bootstrap —prefix=/usr/local — –DCMAKE_BUILD_TYPE:STRING=Release
make
sudo make install
|
重启bash, 查看CMake版本:
命令:
|
|
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的话:
|
|
mkdir –p release
cmake CMakeLists.txt –DCMAKE_INSTALL_PREFIX=./release
make && make install
|
这个是编译完整版,取 libtcmalloc_minimal.a 用即可.
Jsoncpp
|
|
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
|
|
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编译出问题链接到系统版本了);
|
|
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版本。
|
|
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版本冲突导致的问题。
20240923 tkxiong 修改为使用 openssl 3.3.2 版本
curl 修改为使用 7.83.0 版本
下文的want_h2_path, 在7.83.0版本中为: want_nghttp2_pkg_config_path
20240924 tkxiong 这里不应该采用修改 configure 文件的方式,而应该在nghttp2安装目录下新建符号链接从lib指向lib64。
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
|
|
|
./curl –vI –g —http2 “http://121.37.5.232:10000/hello/”
|
问题还是没解决。 —— 最后是curl修复了代码.
libuv
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
…
自适应IP