尝试brpc来升级rpc服务,测试应用过程

2023-09-06,,

照着官方文档来,不过在mac下还是有些小坑

对熟悉c++的人来说很小儿科,但对c++相对比较外行 (只知道基本语法和部分数据结构)的人,还是作不到开箱即用

首先编译
```
If you need to enable cpu/heap profilers in examples:

brew install gperftools
If you need to run tests, install and compile googletest (which is not compiled yet):

git clone https://github.com/google/googletest && cd googletest/googletest && mkdir bld && cd bld && cmake .. && make && sudo mv libgtest* /usr/lib/ && cd -
```

报错

/Users/cclient/Work/Source/googletest/googletest/include/gtest/internal/gtest-param-util-generated.h:67:60: error: expected class name
: public ParamGeneratorInterface< ::std::tuple<T1, T2> > {
^
/Users/cclient/Work/Source/googletest/googletest/include/gtest/internal/gtest-param-util-generated.h:69:18: error: no template named 'tuple' in namespace 'std'
typedef ::std::tuple<T1, T2> ParamType;
~~~~~~~^
/Users/cclient/Work/Source/googletest/googletest/include/gtest/internal/gtest-param-util-generated.h:74:33: warning: 'override' keyword is a C++11 extension
[-Wc++11-extensions]
~CartesianProductGenerator2() override {}
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
119 warnings and 20 errors generated.
make[2]: *** [CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
make[1]: *** [CMakeFiles/gtest.dir/all] Error 2
make: *** [all] Error 2

大量的std错误

查看googletest官方信息

https://github.com/google/googletest/blob/master/googletest/README.md

果然看到
```
C++ Standard Version
An environment that supports C++11 is required in order to successfully build Google Test. One way to ensure this is to specify the standard in the top-level project, for example by using the set(CMAKE_CXX_STANDARD 11) command. If this is not feasible, for example in a C project using Google Test for validation, then it can be specified by adding it to the options for cmake via the DCMAKE_CXX_FLAGS option.

```
更改
vim ../CMakeLists.txt
添加
set(CMAKE_CXX_STANDARD 11)

编译成功

jdeMacBook-Pro:bld cclient$ make
Scanning dependencies of target gtest
[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 50%] Linking CXX static library lib/libgtest.a
[ 50%] Built target gtest
Scanning dependencies of target gtest_main
[ 75%] Building CXX object CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[100%] Linking CXX static library lib/libgtest_main.a

sudo mv libgtest* /usr/lib/ && cd -
#mac 路径 更改至 /usr/local/lib/

sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=clang --cxx=clang++
gnu-getopt must be installed and used

bjdeMacBook-Pro:brpc cclient$ brew reinstall gnu-getopt
==> Reinstalling gnu-getopt
==> Downloading https://homebrew.bintray.com/bottles/gnu-getopt-1.1.6.high_sierra.bottle.tar.gz
Already downloaded: /Users/cclient/Library/Caches/Homebrew/downloads/bb41269c7b4673c442514e69d159a5ec6238d547266318d72d3c067be2ed448f--gnu-getopt-1.1.6.high_sierra.bottle.tar.gz
==> Pouring gnu-getopt-1.1.6.high_sierra.bottle.tar.gz
==> Caveats
gnu-getopt is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have gnu-getopt first in your PATH run:
echo 'export PATH="/usr/local/opt/gnu-getopt/bin:$PATH"' >> ~/.bash_profile

==> Summary

尝试brpc来升级rpc服务,测试应用过程的相关教程结束。

《尝试brpc来升级rpc服务,测试应用过程.doc》

下载本文的Word格式文档,以方便收藏与打印。