You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ja...@apache.org on 2020/12/05 06:51:56 UTC

[incubator-brpc] branch master updated: fix CMakeList.txt in examples and rename BUILD to BUILD.bazel to avoid conflict with cmake

This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new e93e0c2  fix CMakeList.txt in examples and rename BUILD to BUILD.bazel to avoid conflict with cmake
e93e0c2 is described below

commit e93e0c2afef5350a05e18cebf1a9677d345af5ec
Author: jamesge <jg...@gmail.com>
AuthorDate: Sat Dec 5 14:51:40 2020 +0800

    fix CMakeList.txt in examples and rename BUILD to BUILD.bazel to avoid conflict with cmake
---
 BUILD => BUILD.bazel                               |   0
 docs/cn/getting_started.md                         |  87 +++---------
 docs/cn/thrift.md                                  |   2 +-
 docs/en/thrift.md                                  |   2 +-
 example/asynchronous_echo_c++/CMakeLists.txt       |  17 ++-
 example/auto_concurrency_limiter/CMakeLists.txt    |  19 +--
 example/backup_request_c++/CMakeLists.txt          |  17 ++-
 example/cancel_c++/CMakeLists.txt                  |  17 ++-
 example/cascade_echo_c++/CMakeLists.txt            |  17 ++-
 example/dynamic_partition_echo_c++/CMakeLists.txt  |  18 +--
 example/echo_c++/CMakeLists.txt                    |   9 +-
 example/echo_c++_hulu_pbrpc/CMakeLists.txt         | 145 -------------------
 example/echo_c++_hulu_pbrpc/Makefile               |  18 ---
 example/echo_c++_hulu_pbrpc/client.cpp             |  93 ------------
 example/echo_c++_hulu_pbrpc/echo.proto             |  33 -----
 example/echo_c++_hulu_pbrpc/server.cpp             | 120 ----------------
 example/echo_c++_sofa_pbrpc/CMakeLists.txt         | 145 -------------------
 example/echo_c++_sofa_pbrpc/Makefile               |  18 ---
 example/echo_c++_sofa_pbrpc/client.cpp             |  84 -----------
 example/echo_c++_sofa_pbrpc/echo.proto             |  33 -----
 example/echo_c++_sofa_pbrpc/server.cpp             |  98 -------------
 example/echo_c++_ubrpc_compack/CMakeLists.txt      | 150 --------------------
 example/echo_c++_ubrpc_compack/Makefile            |  19 ---
 example/echo_c++_ubrpc_compack/client.cpp          | 133 ------------------
 example/echo_c++_ubrpc_compack/echo.proto          |  67 ---------
 example/echo_c++_ubrpc_compack/idl_options.proto   |  54 -------
 example/echo_c++_ubrpc_compack/server.cpp          | 118 ----------------
 example/grpc_c++/CMakeLists.txt                    |  21 +--
 example/http_c++/CMakeLists.txt                    |  18 +--
 example/memcache_c++/CMakeLists.txt                |  17 ++-
 example/multi_threaded_echo_c++/CMakeLists.txt     |  31 ++--
 example/multi_threaded_echo_fns_c++/CMakeLists.txt |  18 +--
 example/multi_threaded_mcpack_c++/CMakeLists.txt   | 155 --------------------
 example/multi_threaded_mcpack_c++/Makefile         |  19 ---
 example/multi_threaded_mcpack_c++/client.cpp       | 156 ---------------------
 example/multi_threaded_mcpack_c++/echo.proto       |  36 -----
 .../multi_threaded_mcpack_c++/idl_options.proto    |  54 -------
 example/multi_threaded_mcpack_c++/server.cpp       |  83 -----------
 example/nshead_extension_c++/CMakeLists.txt        |  17 ++-
 example/nshead_pb_extension_c++/CMakeLists.txt     |  17 ++-
 example/parallel_echo_c++/CMakeLists.txt           |  18 +--
 example/partition_echo_c++/CMakeLists.txt          |  18 +--
 example/redis_c++/CMakeLists.txt                   |  17 ++-
 example/selective_echo_c++/CMakeLists.txt          |  18 +--
 .../session_data_and_thread_local/CMakeLists.txt   |  14 +-
 example/streaming_echo_c++/CMakeLists.txt          |  17 ++-
 46 files changed, 192 insertions(+), 2085 deletions(-)

diff --git a/BUILD b/BUILD.bazel
similarity index 100%
rename from BUILD
rename to BUILD.bazel
diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md
index 0b70895..4d10ef6 100644
--- a/docs/cn/getting_started.md
+++ b/docs/cn/getting_started.md
@@ -73,28 +73,32 @@ $ sh run_tests.sh
 
 ### Compile brpc with cmake
 ```shell
-mkdir bld && cd bld && cmake .. && make
+cmake -B build && cmake --build build -j6
 ```
-To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
+To help VSCode or Emacs(LSP) to understand code correctly, add `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` to generate `compile_commands.json`
 
-To not link debugging symbols, use `rm -f CMakeCache.txt && cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
+To change compiler to clang, overwrite environment variable `CC` and `CXX` to `clang` and `clang++` respectively.
 
-To use brpc with glog, add `-DWITH_GLOG=ON`.
+To not link debugging symbols, remove `build/CMakeCache.txt` and cmake with `-DWITH_DEBUG_SYMBOLS=OFF`
 
-To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`.
+To use brpc with glog, cmake with `-DWITH_GLOG=ON`.
+
+To enable [thrift support](../en/thrift.md), install thrift first and cmake with `-DWITH_THRIFT=ON`.
 
 **Run example with cmake**
+
 ```shell
 $ cd example/echo_c++
-$ mkdir bld && cd bld && cmake .. && make
+$ cmake -B build && cmake --build build -j4
 $ ./echo_server &
 $ ./echo_client
 ```
-Examples link brpc statically, if you need to link the shared version, use `rm -f CMakeCache.txt && cmake -DLINK_SO=ON ..`
+Examples link brpc statically, if you need to link the shared version, remove `CMakeCache.txt` and cmake with `-DLINK_SO=ON`
 
 **Run tests**
+
 ```shell
-$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make && make test
+$ mkdir build && cd build && cmake -DBUILD_UNIT_TESTS=ON .. && make && make test
 ```
 
 ## Fedora/CentOS
@@ -161,31 +165,7 @@ $ sh run_tests.sh
 ```
 
 ### Compile brpc with cmake
-```shell
-mkdir bld && cd bld && cmake .. && make
-```
-To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
-
-To not link debugging symbols, use `rm -f CMakeCache.txt && cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
-
-To use brpc with glog, add `-DWITH_GLOG=ON`.
-
-To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`.
-
-**Run example**
-
-```shell
-$ cd example/echo_c++
-$ mkdir bld && cd bld && cmake .. && make
-$ ./echo_server &
-$ ./echo_client
-```
-Examples link brpc statically, if you need to link the shared version, use `rm -f CMakeCache.txt && cmake -DLINK_SO=ON ..`
-
-**Run tests**
-```shell
-$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make && make test
-```
+Same with [here](#compile-brpc-with-cmake)
 
 ## Linux with self-built deps
 
@@ -229,20 +209,7 @@ $ make
 ```
 
 ### Compile brpc with cmake
-
-git clone brpc. cd into the repo and run
-
-```shell
-mkdir bld && cd bld && cmake -DCMAKE_INCLUDE_PATH="/path/to/dep1/include;/path/to/dep2/include" -DCMAKE_LIBRARY_PATH="/path/to/dep1/lib;/path/to/dep2/lib" .. && make
-```
-
-To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
-
-To not link debugging symbols, use `rm -f CMakeCache.txt && cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
-
-To use brpc with glog, add `-DWITH_GLOG=ON`.
-
-To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`.
+Same with [here](#compile-brpc-with-cmake)
 
 ## MacOS
 
@@ -267,7 +234,7 @@ brew install gperftools
 
 If you need to run tests, download and compile googletest (which is not compiled yet):
 ```shell
-git clone https://github.com/google/googletest -b release-1.10.0 && cd googletest/googletest && mkdir bld && cd bld && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make
+git clone https://github.com/google/googletest -b release-1.10.0 && cd googletest/googletest && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make
 ```
 After the compilation, copy include/ and lib/ into /usr/local/include and /usr/local/lib respectively to expose gtest to all apps
 
@@ -302,29 +269,7 @@ $ sh run_tests.sh
 ```
 
 ### Compile brpc with cmake
-```shell
-mkdir bld && cd bld && cmake .. && make
-```
-
-To not link debugging symbols, use `rm -f CMakeCache.txt && cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
-
-To use brpc with glog, add `-DWITH_GLOG=ON`.
-
-To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`.
-
-**Run example with cmake**
-```shell
-$ cd example/echo_c++
-$ mkdir bld && cd bld && cmake .. && make
-$ ./echo_server &
-$ ./echo_client
-```
-Examples link brpc statically, if you need to link the shared version, use `rm -f CMakeCache.txt && cmake -DLINK_SO=ON ..`
-
-**Run tests**
-```shell
-$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make && make test
-```
+Same with [here](#compile-brpc-with-cmake)
 
 # Supported deps
 
diff --git a/docs/cn/thrift.md b/docs/cn/thrift.md
index 0f15973..b237ac2 100755
--- a/docs/cn/thrift.md
+++ b/docs/cn/thrift.md
@@ -33,7 +33,7 @@ sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --with-thrift
 # Fedora/CentOS
 sh config_brpc.sh --headers=/usr/include --libs=/usr/lib64 --with-thrift
 # Or use cmake
-mkdir bld && cd bld && cmake ../ -DWITH_THRIFT=1
+mkdir build && cd build && cmake ../ -DWITH_THRIFT=1
 ```
 更多编译选项请阅读[Getting Started](../cn/getting_started.md)。
 
diff --git a/docs/en/thrift.md b/docs/en/thrift.md
index 00a35dc..da8b6fd 100755
--- a/docs/en/thrift.md
+++ b/docs/en/thrift.md
@@ -33,7 +33,7 @@ sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --with-thrift
 # Fedora/CentOS
 sh config_brpc.sh --headers=/usr/include --libs=/usr/lib64 --with-thrift
 # Or use cmake
-mkdir bld && cd bld && cmake ../ -DWITH_THRIFT=ON
+mkdir build && cd build && cmake ../ -DWITH_THRIFT=ON
 ```
 Read [Getting Started](../cn/getting_started.md) for more compilation options.
 
diff --git a/example/asynchronous_echo_c++/CMakeLists.txt b/example/asynchronous_echo_c++/CMakeLists.txt
index 3bc4e5e..18fec20 100644
--- a/example/asynchronous_echo_c++/CMakeLists.txt
+++ b/example/asynchronous_echo_c++/CMakeLists.txt
@@ -102,23 +102,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/auto_concurrency_limiter/CMakeLists.txt b/example/auto_concurrency_limiter/CMakeLists.txt
index 5d02afb..ef20bf0 100644
--- a/example/auto_concurrency_limiter/CMakeLists.txt
+++ b/example/auto_concurrency_limiter/CMakeLists.txt
@@ -91,23 +91,24 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
+    ${THRIFT_LIB}
+    ${THRIFTNB_LIB}
     dl
     )
 
diff --git a/example/backup_request_c++/CMakeLists.txt b/example/backup_request_c++/CMakeLists.txt
index 10f7715..d247bc1 100644
--- a/example/backup_request_c++/CMakeLists.txt
+++ b/example/backup_request_c++/CMakeLists.txt
@@ -102,23 +102,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/cancel_c++/CMakeLists.txt b/example/cancel_c++/CMakeLists.txt
index d501a2a..26f2581 100644
--- a/example/cancel_c++/CMakeLists.txt
+++ b/example/cancel_c++/CMakeLists.txt
@@ -102,23 +102,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/cascade_echo_c++/CMakeLists.txt b/example/cascade_echo_c++/CMakeLists.txt
index 2218e36..24d9249 100644
--- a/example/cascade_echo_c++/CMakeLists.txt
+++ b/example/cascade_echo_c++/CMakeLists.txt
@@ -101,23 +101,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/dynamic_partition_echo_c++/CMakeLists.txt b/example/dynamic_partition_echo_c++/CMakeLists.txt
index d095ca8..5a268a6 100644
--- a/example/dynamic_partition_echo_c++/CMakeLists.txt
+++ b/example/dynamic_partition_echo_c++/CMakeLists.txt
@@ -107,23 +107,23 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/echo_c++/CMakeLists.txt b/example/echo_c++/CMakeLists.txt
index e751076..4e6f523 100644
--- a/example/echo_c++/CMakeLists.txt
+++ b/example/echo_c++/CMakeLists.txt
@@ -107,11 +107,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
         "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
         )
 endif()
-include_directories(${OPENSSL_INCLUDE_DIR})
-find_package(OpenSSL)
 
-add_executable(echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
-add_executable(echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
@@ -139,5 +137,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
         "-Wl,-U,_ProfilerStop")
 endif()
 
+add_executable(echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
+add_executable(echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
+
 target_link_libraries(echo_client ${BRPC_LIB} ${DYNAMIC_LIB})
 target_link_libraries(echo_server ${BRPC_LIB} ${DYNAMIC_LIB})
diff --git a/example/echo_c++_hulu_pbrpc/CMakeLists.txt b/example/echo_c++_hulu_pbrpc/CMakeLists.txt
deleted file mode 100644
index 21da70c..0000000
--- a/example/echo_c++_hulu_pbrpc/CMakeLists.txt
+++ /dev/null
@@ -1,145 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-cmake_minimum_required(VERSION 2.8.10)
-project(echo_c++_hulu_pbrpc C CXX)
-
-option(LINK_SO "Whether examples are linked dynamically" OFF)
-
-execute_process(
-    COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
-    OUTPUT_VARIABLE OUTPUT_PATH
-)
-
-set(CMAKE_PREFIX_PATH ${OUTPUT_PATH})
-
-include(FindThreads)
-include(FindProtobuf)
-protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
-# include PROTO_HEADER
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# Search for libthrift* by best effort. If it is not found and brpc is
-# compiled with thrift protocol enabled, a link error would be reported.
-find_library(THRIFT_LIB NAMES thrift)
-if (NOT THRIFT_LIB)
-    set(THRIFT_LIB "")
-endif()
-find_library(THRIFTNB_LIB NAMES thriftnb)
-if (NOT THRIFTNB_LIB)
-    set(THRIFTNB_LIB "")
-endif()
-
-find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
-if(LINK_SO)
-    find_library(BRPC_LIB NAMES brpc)
-else()
-    find_library(BRPC_LIB NAMES libbrpc.a brpc)
-endif()
-if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
-    message(FATAL_ERROR "Fail to find brpc")
-endif()
-include_directories(${BRPC_INCLUDE_PATH})
-
-find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h)
-find_library(GFLAGS_LIBRARY NAMES gflags libgflags)
-if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
-    message(FATAL_ERROR "Fail to find gflags")
-endif()
-include_directories(${GFLAGS_INCLUDE_PATH})
-
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    include(CheckFunctionExists)
-    CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
-    if(NOT HAVE_CLOCK_GETTIME)
-        set(DEFINE_CLOCK_GETTIME "-DNO_CLOCK_GETTIME_IN_MAC")
-    endif()
-endif()
-
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
-
-if(CMAKE_VERSION VERSION_LESS "3.1.3")
-    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-    endif()
-    if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-    endif()
-else()
-    set(CMAKE_CXX_STANDARD 11)
-    set(CMAKE_CXX_STANDARD_REQUIRED ON)
-endif()
-
-find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h)
-find_library(LEVELDB_LIB NAMES leveldb)
-if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
-    message(FATAL_ERROR "Fail to find leveldb")
-endif()
-include_directories(${LEVELDB_INCLUDE_PATH})
-
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
-endif()
-
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
-
-set(DYNAMIC_LIB
-    ${CMAKE_THREAD_LIBS_INIT}
-    ${GFLAGS_LIBRARY}
-    ${PROTOBUF_LIBRARIES}
-    ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
-    ${THRIFT_LIB}
-    ${THRIFTNB_LIB}
-    dl
-    )
-
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    set(DYNAMIC_LIB ${DYNAMIC_LIB}
-        pthread
-        "-framework CoreFoundation"
-        "-framework CoreGraphics"
-        "-framework CoreData"
-        "-framework CoreText"
-        "-framework Security"
-        "-framework Foundation"
-        "-Wl,-U,_MallocExtension_ReleaseFreeMemory"
-        "-Wl,-U,_ProfilerStart"
-        "-Wl,-U,_ProfilerStop")
-endif()
-
-add_executable(echo_hulu_pbrpc_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
-add_executable(echo_hulu_pbrpc_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
-
-target_link_libraries(echo_hulu_pbrpc_client ${BRPC_LIB} ${DYNAMIC_LIB})
-target_link_libraries(echo_hulu_pbrpc_server ${BRPC_LIB} ${DYNAMIC_LIB})
diff --git a/example/echo_c++_hulu_pbrpc/Makefile b/example/echo_c++_hulu_pbrpc/Makefile
deleted file mode 100644
index 7757b2b..0000000
--- a/example/echo_c++_hulu_pbrpc/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include ../echo_c++/Makefile
diff --git a/example/echo_c++_hulu_pbrpc/client.cpp b/example/echo_c++_hulu_pbrpc/client.cpp
deleted file mode 100644
index eeb9995..0000000
--- a/example/echo_c++_hulu_pbrpc/client.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// A client sending requests to server every 1 second.
-
-#include <gflags/gflags.h>
-#include <butil/logging.h>
-#include <butil/time.h>
-#include <brpc/channel.h>
-#include <brpc/policy/hulu_pbrpc_controller.h>
-#include "echo.pb.h"
-
-DEFINE_string(attachment, "", "Carry this along with requests");
-DEFINE_string(connection_type, "", "Connection type. Available values: single, pooled, short");
-DEFINE_string(server, "0.0.0.0:8000", "IP Address of server");
-DEFINE_string(load_balancer, "", "The algorithm for load balancing");
-DEFINE_int32(timeout_ms, 100, "RPC timeout in milliseconds");
-DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); 
-DEFINE_int32(interval_ms, 1000, "Milliseconds between consecutive requests");
-
-int main(int argc, char* argv[]) {
-    // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
-    
-    // A Channel represents a communication line to a Server. Notice that 
-    // Channel is thread-safe and can be shared by all threads in your program.
-    brpc::Channel channel;
-    
-    // Initialize the channel, NULL means using default options.
-    brpc::ChannelOptions options;
-    options.protocol = "hulu_pbrpc";
-    options.connection_type = FLAGS_connection_type;
-    options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/;
-    options.max_retry = FLAGS_max_retry;
-    if (channel.Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) {
-        LOG(ERROR) << "Fail to initialize channel";
-        return -1;
-    }
-
-    // Normally, you should not call a Channel directly, but instead construct
-    // a stub Service wrapping it. stub can be shared by all threads as well.
-    example::EchoService_Stub stub(&channel);
-
-    // Send a request and wait for the response every 1 second.
-    int log_id = 0;
-    while (!brpc::IsAskedToQuit()) {
-        // We will receive response synchronously, safe to put variables
-        // on stack.
-        example::EchoRequest request;
-        example::EchoResponse response;
-        brpc::policy::HuluController cntl;
-
-        request.set_message("hello world");
-
-        cntl.set_log_id(log_id++);  // set by user
-        cntl.request_attachment().append(FLAGS_attachment);
-        cntl.set_request_source_addr(log_id++);
-        cntl.set_request_user_data("client user data");
-
-        // Because `done'(last parameter) is NULL, this function waits until
-        // the response comes back or error occurs(including timedout).
-        stub.Echo(&cntl, &request, &response, NULL);
-        if (!cntl.Failed()) {
-            LOG(INFO) << "Received response from " << cntl.remote_side()
-                << " to " << cntl.local_side()
-                << ": " << response.message() << " (attached="
-                << cntl.response_attachment() << ")"
-                << " response_source_addr=" << cntl.response_source_addr()
-                << " response_user_data=\"" << cntl.response_user_data()
-                << "\" latency=" << cntl.latency_us() << "us";
-        } else {
-            LOG(WARNING) << cntl.ErrorText();
-        }
-        usleep(FLAGS_interval_ms * 1000L);
-    }
-
-    LOG(INFO) << "EchoClient is going to quit";
-    return 0;
-}
diff --git a/example/echo_c++_hulu_pbrpc/echo.proto b/example/echo_c++_hulu_pbrpc/echo.proto
deleted file mode 100644
index 2b39627..0000000
--- a/example/echo_c++_hulu_pbrpc/echo.proto
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-syntax="proto2";
-package example;
-
-option cc_generic_services = true;
-
-message EchoRequest {
-      required string message = 1;
-};
-
-message EchoResponse {
-      required string message = 1;
-};
-
-service EchoService {
-      rpc Echo(EchoRequest) returns (EchoResponse);
-};
diff --git a/example/echo_c++_hulu_pbrpc/server.cpp b/example/echo_c++_hulu_pbrpc/server.cpp
deleted file mode 100644
index 70a7951..0000000
--- a/example/echo_c++_hulu_pbrpc/server.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// A server to receive EchoRequest and send back EchoResponse.
-
-#include <gflags/gflags.h>
-#include <butil/logging.h>
-#include <brpc/server.h>
-#include <brpc/policy/hulu_pbrpc_controller.h>
-#include "echo.pb.h"
-
-DEFINE_bool(echo_attachment, true, "Echo attachment as well");
-DEFINE_int32(port, 8000, "TCP Port of this server");
-DEFINE_int32(idle_timeout_s, -1, "Connection will be closed if there is no "
-             "read/write operations during the last `idle_timeout_s'");
-DEFINE_int32(logoff_ms, 2000, "Maximum duration of server's LOGOFF state "
-             "(waiting for client to close connection before server stops)");
-
-// Your implementation of example::EchoService
-// Notice that implementing brpc::Describable grants the ability to put
-// additional information in /status.
-namespace example {
-class EchoServiceImpl : public EchoService {
-public:
-    EchoServiceImpl() {};
-    virtual ~EchoServiceImpl() {};
-    virtual void Echo(google::protobuf::RpcController* cntl_base,
-                      const EchoRequest* request,
-                      EchoResponse* response,
-                      google::protobuf::Closure* done) {
-        // This object helps you to call done->Run() in RAII style. If you need
-        // to process the request asynchronously, pass done_guard.release().
-        brpc::ClosureGuard done_guard(done);
-
-        brpc::Controller* cntl =
-            static_cast<brpc::Controller*>(cntl_base);
-
-        // The purpose of following logs is to help you to understand
-        // how clients interact with servers more intuitively. You should 
-        // remove these logs in performance-sensitive servers.
-        LOG(INFO) << "Received request[log_id=" << cntl->log_id() 
-                  << "] from " << cntl->remote_side() 
-                  << " to " << cntl->local_side()
-                  << ": " << request->message()
-                  << " (attached=" << cntl->request_attachment() << ")";
-        brpc::policy::HuluController* hulu_controller
-                = dynamic_cast<brpc::policy::HuluController*>(cntl);
-        if (hulu_controller) {
-            LOG(INFO) << "source_addr="
-                      << hulu_controller->request_source_addr()
-                      << " user_data=\"" << hulu_controller->request_user_data()
-                      << '\"';
-        }
-
-        // Fill response.
-        response->set_message(request->message());
-
-        // You can compress the response by setting Controller, but be aware
-        // that compression may be costly, evaluate before turning on.
-        // cntl->set_response_compress_type(brpc::COMPRESS_TYPE_GZIP);
-
-        if (FLAGS_echo_attachment) {
-            // Set attachment which is wired to network directly instead of
-            // being serialized into protobuf messages.
-            cntl->response_attachment().append(cntl->request_attachment());
-        }
-        if (hulu_controller) {
-            hulu_controller->set_response_source_addr(
-                    hulu_controller->request_source_addr() + 1);
-            hulu_controller->set_response_user_data("server user data");
-        }
-    }
-};
-}  // namespace example
-
-int main(int argc, char* argv[]) {
-    // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
-
-    // Generally you only need one Server.
-    brpc::Server server;
-
-    // Instance of your service.
-    example::EchoServiceImpl echo_service_impl;
-
-    // Add the service into server. Notice the second parameter, because the
-    // service is put on stack, we don't want server to delete it, otherwise
-    // use brpc::SERVER_OWNS_SERVICE.
-    if (server.AddService(&echo_service_impl, 
-                          brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
-        LOG(ERROR) << "Fail to add service";
-        return -1;
-    }
-
-    // Start the server.
-    brpc::ServerOptions options;
-    options.idle_timeout_sec = FLAGS_idle_timeout_s;
-    if (server.Start(FLAGS_port, &options) != 0) {
-        LOG(ERROR) << "Fail to start EchoServer";
-        return -1;
-    }
-
-    // Wait until Ctrl-C is pressed, then Stop() and Join() the server.
-    server.RunUntilAskedToQuit();
-    return 0;
-}
diff --git a/example/echo_c++_sofa_pbrpc/CMakeLists.txt b/example/echo_c++_sofa_pbrpc/CMakeLists.txt
deleted file mode 100644
index f605730..0000000
--- a/example/echo_c++_sofa_pbrpc/CMakeLists.txt
+++ /dev/null
@@ -1,145 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-cmake_minimum_required(VERSION 2.8.10)
-project(echo_c++_sofa_pbrpc C CXX)
-
-option(LINK_SO "Whether examples are linked dynamically" OFF)
-
-execute_process(
-    COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
-    OUTPUT_VARIABLE OUTPUT_PATH
-)
-
-set(CMAKE_PREFIX_PATH ${OUTPUT_PATH})
-
-include(FindThreads)
-include(FindProtobuf)
-protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
-# include PROTO_HEADER
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# Search for libthrift* by best effort. If it is not found and brpc is
-# compiled with thrift protocol enabled, a link error would be reported.
-find_library(THRIFT_LIB NAMES thrift)
-if (NOT THRIFT_LIB)
-    set(THRIFT_LIB "")
-endif()
-find_library(THRIFTNB_LIB NAMES thriftnb)
-if (NOT THRIFTNB_LIB)
-    set(THRIFTNB_LIB "")
-endif()
-
-find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
-if(LINK_SO)
-    find_library(BRPC_LIB NAMES brpc)
-else()
-    find_library(BRPC_LIB NAMES libbrpc.a brpc)
-endif()
-if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
-    message(FATAL_ERROR "Fail to find brpc")
-endif()
-include_directories(${BRPC_INCLUDE_PATH})
-
-find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h)
-find_library(GFLAGS_LIBRARY NAMES gflags libgflags)
-if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
-    message(FATAL_ERROR "Fail to find gflags")
-endif()
-include_directories(${GFLAGS_INCLUDE_PATH})
-
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    include(CheckFunctionExists)
-    CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
-    if(NOT HAVE_CLOCK_GETTIME)
-        set(DEFINE_CLOCK_GETTIME "-DNO_CLOCK_GETTIME_IN_MAC")
-    endif()
-endif()
-
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
-
-if(CMAKE_VERSION VERSION_LESS "3.1.3")
-    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-    endif()
-    if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-    endif()
-else()
-    set(CMAKE_CXX_STANDARD 11)
-    set(CMAKE_CXX_STANDARD_REQUIRED ON)
-endif()
-
-find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h)
-find_library(LEVELDB_LIB NAMES leveldb)
-if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
-    message(FATAL_ERROR "Fail to find leveldb")
-endif()
-include_directories(${LEVELDB_INCLUDE_PATH})
-
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
-endif()
-
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
-
-set(DYNAMIC_LIB
-    ${CMAKE_THREAD_LIBS_INIT}
-    ${GFLAGS_LIBRARY}
-    ${PROTOBUF_LIBRARIES}
-    ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
-    ${THRIFT_LIB}
-    ${THRIFTNB_LIB}
-    dl
-    )
-
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    set(DYNAMIC_LIB ${DYNAMIC_LIB}
-        pthread
-        "-framework CoreFoundation"
-        "-framework CoreGraphics"
-        "-framework CoreData"
-        "-framework CoreText"
-        "-framework Security"
-        "-framework Foundation"
-        "-Wl,-U,_MallocExtension_ReleaseFreeMemory"
-        "-Wl,-U,_ProfilerStart"
-        "-Wl,-U,_ProfilerStop")
-endif()
-
-add_executable(echo_sofa_pbrpc_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
-add_executable(echo_sofa_pbrpc_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
-
-target_link_libraries(echo_sofa_pbrpc_client ${BRPC_LIB} ${DYNAMIC_LIB})
-target_link_libraries(echo_sofa_pbrpc_server ${BRPC_LIB} ${DYNAMIC_LIB})
diff --git a/example/echo_c++_sofa_pbrpc/Makefile b/example/echo_c++_sofa_pbrpc/Makefile
deleted file mode 100644
index 7757b2b..0000000
--- a/example/echo_c++_sofa_pbrpc/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include ../echo_c++/Makefile
diff --git a/example/echo_c++_sofa_pbrpc/client.cpp b/example/echo_c++_sofa_pbrpc/client.cpp
deleted file mode 100644
index fef815e..0000000
--- a/example/echo_c++_sofa_pbrpc/client.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// A client sending requests to server every 1 second.
-
-#include <gflags/gflags.h>
-#include <butil/logging.h>
-#include <butil/time.h>
-#include <brpc/channel.h>
-#include "echo.pb.h"
-
-DEFINE_string(connection_type, "","Connection type. Available values: single, pooled, short");
-DEFINE_string(server, "0.0.0.0:8000", "IP Address of server");
-DEFINE_string(load_balancer, "", "The algorithm for load balancing");
-DEFINE_int32(timeout_ms, 100, "RPC timeout in milliseconds");
-DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); 
-DEFINE_string(protocol, "sofa_pbrpc", "Protocol type. Defined in src/brpc/options.proto");
-
-int main(int argc, char* argv[]) {
-    // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
-    
-    // A Channel represents a communication line to a Server. Notice that 
-    // Channel is thread-safe and can be shared by all threads in your program.
-    brpc::Channel channel;
-    
-    // Initialize the channel, NULL means using default options. 
-    brpc::ChannelOptions options;
-    options.protocol = FLAGS_protocol;
-    options.connection_type = FLAGS_connection_type;
-    options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/;
-    options.max_retry = FLAGS_max_retry;
-    if (channel.Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) {
-        LOG(ERROR) << "Fail to initialize channel";
-        return -1;
-    }
-
-    // Normally, you should not call a Channel directly, but instead construct
-    // a stub Service wrapping it. stub can be shared by all threads as well.
-    example::EchoService_Stub stub(&channel);
-
-    // Send a request and wait for the response every 1 second.
-    int log_id = 0;
-    while (!brpc::IsAskedToQuit()) {
-        // We will receive response synchronously, safe to put variables
-        // on stack.
-        example::EchoRequest request;
-        example::EchoResponse response;
-        brpc::Controller cntl;
-
-        request.set_message("hello world");
-
-        cntl.set_log_id(log_id ++);  // set by user
-
-        // Because `done'(last parameter) is NULL, this function waits until
-        // the response comes back or error occurs(including timedout).
-        stub.Echo(&cntl, &request, &response, NULL);
-        if (!cntl.Failed()) {
-            LOG(INFO) << "Received response from " << cntl.remote_side()
-                << ": " << response.message()
-                << " latency=" << cntl.latency_us() << "us";
-        } else {
-            LOG(WARNING) << "Fail to send EchoRequest, " << cntl.ErrorText();
-        }
-        sleep(1);
-    }
-
-    LOG(INFO) << "EchoClient is going to quit";
-    return 0;
-}
diff --git a/example/echo_c++_sofa_pbrpc/echo.proto b/example/echo_c++_sofa_pbrpc/echo.proto
deleted file mode 100644
index 2b39627..0000000
--- a/example/echo_c++_sofa_pbrpc/echo.proto
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-syntax="proto2";
-package example;
-
-option cc_generic_services = true;
-
-message EchoRequest {
-      required string message = 1;
-};
-
-message EchoResponse {
-      required string message = 1;
-};
-
-service EchoService {
-      rpc Echo(EchoRequest) returns (EchoResponse);
-};
diff --git a/example/echo_c++_sofa_pbrpc/server.cpp b/example/echo_c++_sofa_pbrpc/server.cpp
deleted file mode 100644
index ef3c0f1..0000000
--- a/example/echo_c++_sofa_pbrpc/server.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// A server to receive EchoRequest and send back EchoResponse.
-
-#include <gflags/gflags.h>
-#include <butil/logging.h>
-#include <brpc/server.h>
-#include "echo.pb.h"
-
-DEFINE_int32(port, 8000, "TCP Port of this server");
-DEFINE_int32(idle_timeout_s, -1, "Connection will be closed if there is no "
-             "read/write operations during the last `idle_timeout_s'");
-DEFINE_int32(logoff_ms, 2000, "Maximum duration of server's LOGOFF state "
-             "(waiting for client to close connection before server stops)");
-
-// Your implementation of example::EchoService
-// Notice that implementing brpc::Describable grants the ability to put
-// additional information in /status.
-namespace example {
-class EchoServiceImpl : public EchoService {
-public:
-    EchoServiceImpl() {};
-    virtual ~EchoServiceImpl() {};
-    virtual void Echo(google::protobuf::RpcController* cntl_base,
-                      const EchoRequest* request,
-                      EchoResponse* response,
-                      google::protobuf::Closure* done) {
-        // This object helps you to call done->Run() in RAII style. If you need
-        // to process the request asynchronously, pass done_guard.release().
-        brpc::ClosureGuard done_guard(done);
-
-        brpc::Controller* cntl =
-            static_cast<brpc::Controller*>(cntl_base);
-
-        // The purpose of following logs is to help you to understand
-        // how clients interact with servers more intuitively. You should 
-        // remove these logs in performance-sensitive servers.
-        LOG(INFO) << "Received request[log_id=" << cntl->log_id() 
-                  << "] from " << cntl->remote_side() 
-                  << " to " << cntl->local_side()
-                  << ": " << request->message();
-
-        // Fill response.
-        response->set_message(request->message());
-
-        // You can compress the response by setting Controller, but be aware
-        // that compression may be costly, evaluate before turning on.
-        // cntl->set_response_compress_type(brpc::COMPRESS_TYPE_GZIP);
-    }
-};
-}  // namespace example
-
-int main(int argc, char* argv[]) {
-    // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
-
-    // Generally you only need one Server.
-    brpc::Server server;
-
-    // Instance of your service.
-    example::EchoServiceImpl echo_service_impl;
-
-    // Add the service into server. Notice the second parameter, because the
-    // service is put on stack, we don't want server to delete it, otherwise
-    // use brpc::SERVER_OWNS_SERVICE.
-    if (server.AddService(&echo_service_impl, 
-                          brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
-        LOG(ERROR) << "Fail to add service";
-        return -1;
-    }
-
-    // Start the server.
-    brpc::ServerOptions options;
-    options.idle_timeout_sec = FLAGS_idle_timeout_s;
-    if (server.Start(FLAGS_port, &options) != 0) {
-        LOG(ERROR) << "Fail to start EchoServer";
-        return -1;
-    }
-
-    // Wait until Ctrl-C is pressed, then Stop() and Join() the server.
-    server.RunUntilAskedToQuit();
-    return 0;
-}
diff --git a/example/echo_c++_ubrpc_compack/CMakeLists.txt b/example/echo_c++_ubrpc_compack/CMakeLists.txt
deleted file mode 100644
index dcc5097..0000000
--- a/example/echo_c++_ubrpc_compack/CMakeLists.txt
+++ /dev/null
@@ -1,150 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-cmake_minimum_required(VERSION 2.8.10)
-project(echo_c++_ubrpc_compack C CXX)
-
-option(LINK_SO "Whether examples are linked dynamically" OFF)
-
-execute_process(
-    COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
-    OUTPUT_VARIABLE OUTPUT_PATH
-)
-
-set(CMAKE_PREFIX_PATH ${OUTPUT_PATH})
-
-include(FindThreads)
-include(FindProtobuf)
-protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
-# include PROTO_HEADER
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# Search for libthrift* by best effort. If it is not found and brpc is
-# compiled with thrift protocol enabled, a link error would be reported.
-find_library(THRIFT_LIB NAMES thrift)
-if (NOT THRIFT_LIB)
-    set(THRIFT_LIB "")
-endif()
-find_library(THRIFTNB_LIB NAMES thriftnb)
-if (NOT THRIFTNB_LIB)
-    set(THRIFTNB_LIB "")
-endif()
-
-find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
-if(LINK_SO)
-    find_library(BRPC_LIB NAMES brpc)
-else()
-    find_library(BRPC_LIB NAMES libbrpc.a brpc)
-endif()
-if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
-    message(FATAL_ERROR "Fail to find brpc")
-endif()
-include_directories(${BRPC_INCLUDE_PATH})
-
-find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h)
-find_library(GFLAGS_LIBRARY NAMES gflags libgflags)
-if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
-    message(FATAL_ERROR "Fail to find gflags")
-endif()
-include_directories(${GFLAGS_INCLUDE_PATH})
-
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    include(CheckFunctionExists)
-    CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
-    if(NOT HAVE_CLOCK_GETTIME)
-        set(DEFINE_CLOCK_GETTIME "-DNO_CLOCK_GETTIME_IN_MAC")
-    endif()
-endif()
-
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
-
-if(CMAKE_VERSION VERSION_LESS "3.1.3")
-    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-    endif()
-    if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-    endif()
-else()
-    set(CMAKE_CXX_STANDARD 11)
-    set(CMAKE_CXX_STANDARD_REQUIRED ON)
-endif()
-
-find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h)
-find_library(LEVELDB_LIB NAMES leveldb)
-if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
-    message(FATAL_ERROR "Fail to find leveldb")
-endif()
-include_directories(${LEVELDB_INCLUDE_PATH})
-
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
-endif()
-
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
-
-set(DYNAMIC_LIB
-    ${CMAKE_THREAD_LIBS_INIT}
-    ${GFLAGS_LIBRARY}
-    ${PROTOBUF_LIBRARIES}
-    ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
-    ${THRIFT_LIB}
-    ${THRIFTNB_LIB}
-    dl
-    )
-
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    set(DYNAMIC_LIB ${DYNAMIC_LIB}
-        pthread
-        "-framework CoreFoundation"
-        "-framework CoreGraphics"
-        "-framework CoreData"
-        "-framework CoreText"
-        "-framework Security"
-        "-framework Foundation"
-        "-Wl,-U,_MallocExtension_ReleaseFreeMemory"
-        "-Wl,-U,_ProfilerStart"
-        "-Wl,-U,_ProfilerStop")
-endif()
-
-execute_process(
-    COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${PROJECT_SOURCE_DIR} --plugin=protoc-gen-mcpack=${OUTPUT_PATH}/bin/protoc-gen-mcpack --mcpack_out=${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/echo.proto
-	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-add_executable(echo_ubrpc_compack_client client.cpp ${CMAKE_CURRENT_BINARY_DIR}/echo.pb.cc)
-add_executable(echo_ubrpc_compack_server server.cpp ${CMAKE_CURRENT_BINARY_DIR}/echo.pb.cc)
-
-target_link_libraries(echo_ubrpc_compack_client ${BRPC_LIB} ${DYNAMIC_LIB})
-target_link_libraries(echo_ubrpc_compack_server ${BRPC_LIB} ${DYNAMIC_LIB})
diff --git a/example/echo_c++_ubrpc_compack/Makefile b/example/echo_c++_ubrpc_compack/Makefile
deleted file mode 100644
index 104ad49..0000000
--- a/example/echo_c++_ubrpc_compack/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-PROTOC_EXTRA_ARGS = --plugin=protoc-gen-mcpack=$(BRPC_PATH)/output/bin/protoc-gen-mcpack --proto_path=$(BRPC_PATH)/output/include --proto_path=$(PROTOBUF_HDR) --mcpack_out=. 
-include ../echo_c++/Makefile
diff --git a/example/echo_c++_ubrpc_compack/client.cpp b/example/echo_c++_ubrpc_compack/client.cpp
deleted file mode 100644
index 6785a23..0000000
--- a/example/echo_c++_ubrpc_compack/client.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// A client sending requests to ubrpc server every 1 second.
-// This client can access the server in public/baidu-rpc-ub/example/echo_c++_compack_ubrpc as well.
-
-#include <gflags/gflags.h>
-
-#include <butil/logging.h>
-#include <butil/time.h>
-#include <brpc/channel.h>
-#include "echo.pb.h"
-
-DEFINE_string(server, "0.0.0.0:8500", "IP Address of server");
-DEFINE_string(load_balancer, "", "The algorithm for load balancing");
-DEFINE_int32(timeout_ms, 100, "RPC timeout in milliseconds");
-DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)");
-DEFINE_bool(multi_args, false,
-            "The ubrpc to be accessed has more than one request and response");
-
-int main(int argc, char* argv[]) {
-    // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
-    
-    // A Channel represents a communication line to a Server. Notice that 
-    // Channel is thread-safe and can be shared by all threads in your program.
-    brpc::Channel channel;
-    
-    // Initialize the channel, NULL means using default options. 
-    brpc::ChannelOptions options;
-    options.protocol = "ubrpc_compack";
-    options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/;
-    options.max_retry = FLAGS_max_retry;
-    if (channel.Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) {
-        LOG(ERROR) << "Fail to initialize channel";
-        return -1;
-    }
-
-    example::EchoService_Stub stub(&channel);
-    example::EchoRequest request;
-    example::EchoResponse response;
-    example::MultiRequests multi_requests;
-    example::MultiResponses multi_responses;
-    brpc::Controller cntl;
-    
-    // Send a request and wait for the response every 1 second.
-    int log_id = 0;
-    while (!brpc::IsAskedToQuit()) {
-        // Reset before reuse.
-        cntl.Reset();
-        
-        if (!FLAGS_multi_args) {
-            request.Clear();
-            response.Clear();
-            request.set_message("hello world");
-            for (int i = (log_id % 7); i > 0; --i) {
-                example::Object* obj = request.add_objects();
-                obj->set_id(log_id);
-                if (log_id % 2 == 0) {
-                    obj->set_value(log_id);
-                }
-                if (log_id % 3 == 0) {
-                    obj->set_note("foo");
-                }
-                if (log_id % 5 == 0) {
-                    for (int j = (log_id % 3); j > 0; --j) {
-                        example::Parameter* param = obj->add_params();
-                        if (log_id % 2 == 0) {
-                            param->set_x(log_id);
-                        }
-                        if (log_id % 3 == 0) {
-                            param->set_y("bar");
-                        }
-                        if (log_id % 5 == 0) {
-                            param->set_z(log_id);
-                        }
-                    }
-                }
-            }
-        } else {
-            multi_requests.Clear();
-            multi_responses.Clear();
-            multi_requests.mutable_req1()->set_message("hello");
-            multi_requests.mutable_req2()->set_message("world");
-            cntl.set_idl_names(brpc::idl_multi_req_multi_res);
-        }
-        cntl.set_log_id(log_id ++);  // set by user
-
-        // Because `done'(last parameter) is NULL, this function waits until
-        // the response comes back or error occurs(including timedout).
-        if (!FLAGS_multi_args) {
-            // [idl] void Echo(EchoRequest req, out EchoResponse res);
-            stub.Echo(&cntl, &request, &response, NULL);
-        } else {
-            // [idl] uint32_t EchoWithMultiArgs(EchoRequest req1, EchoRequest req2, 
-            //                                     out EchoResponse res1, out EchoResponse res2);
-            stub.EchoWithMultiArgs(&cntl, &multi_requests, &multi_responses, NULL);
-        }
-        if (!cntl.Failed()) {
-            if (!FLAGS_multi_args) {
-                LOG(INFO) << "Received response from " << cntl.remote_side()
-                          << ": " << response.message()
-                          << " latency=" << cntl.latency_us() << "us";
-            } else {
-                LOG(INFO) << "Received response from " << cntl.remote_side()
-                          << ": res1=" << multi_responses.res1().message()
-                          << " res2=" << multi_responses.res2().message()
-                          << " result=" << cntl.idl_result()
-                          << " latency=" << cntl.latency_us() << "us";
-            }
-        } else {
-            LOG(ERROR) << "Fail to send request, " << cntl.ErrorText();
-        }
-        sleep(1);
-    }
-
-    LOG(INFO) << "EchoClient is going to quit";
-    return 0;
-}
diff --git a/example/echo_c++_ubrpc_compack/echo.proto b/example/echo_c++_ubrpc_compack/echo.proto
deleted file mode 100644
index bc99d55..0000000
--- a/example/echo_c++_ubrpc_compack/echo.proto
+++ /dev/null
@@ -1,67 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-syntax="proto2";
-// Converted from echo.idl by brpc/tools/idl2proto
-import "idl_options.proto";
-option (idl_support) = true;
-option cc_generic_services = true;
-
-package example;
-
-message Parameter {
-  optional int32 x = 1;
-  optional string y = 2;
-  optional int64 z = 3;
-}
-
-message Object {
-  required int32 id = 1 [(idl_type)=IDL_INT8];
-  optional int32 value = 2;
-  optional string note = 3;
-  repeated Parameter params = 4;
-}
-
-message EchoRequest {
-  required string message = 1; 
-  repeated Object objects = 2;
-}
-
-message EchoResponse {
-  required string message = 1; 
-  repeated Object objects = 2;
-}
-
-message MultiRequests {
-  required EchoRequest req1 = 1;
-  required EchoRequest req2 = 2;
-}
-
-message MultiResponses {
-  required EchoRequest res1 = 1;
-  required EchoRequest res2 = 2;
-}
-
-
-service EchoService {
-  // [idl] void Echo(EchoRequest req, out EchoResponse res);
-  rpc Echo(EchoRequest) returns (EchoResponse);
-
-  // [idl] uint32_t EchoWithMultiArgs(EchoRequest req1, EchoRequest req2, 
-  //                                     out EchoResponse res1, out EchoResponse res2);
-  rpc EchoWithMultiArgs(MultiRequests) returns (MultiResponses);
-}
diff --git a/example/echo_c++_ubrpc_compack/idl_options.proto b/example/echo_c++_ubrpc_compack/idl_options.proto
deleted file mode 100644
index 5687699..0000000
--- a/example/echo_c++_ubrpc_compack/idl_options.proto
+++ /dev/null
@@ -1,54 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-syntax="proto2";
-// mcpack2pb - Make protobuf be front-end of mcpack/compack
-
-import "google/protobuf/descriptor.proto";
-
-extend google.protobuf.FileOptions {
-  // True to generate mcpack parsing/serializing code
-  optional bool idl_support = 91000;
-}
-
-enum ConvertibleIdlType {
-  IDL_AUTO = 0;
-  IDL_INT8 = 1;
-  IDL_INT16 = 2;
-  IDL_INT32 = 3;
-  IDL_INT64 = 4;
-  IDL_UINT8 = 5;
-  IDL_UINT16 = 6;
-  IDL_UINT32 = 7;
-  IDL_UINT64 = 8;
-  IDL_BOOL = 9;
-  IDL_FLOAT = 10;
-  IDL_DOUBLE = 11;
-  IDL_BINARY = 12;
-  IDL_STRING = 13;
-}
-
-extend google.protobuf.FieldOptions {
-  // Mark the idl-type which is inconsistent with proto-type.
-  optional ConvertibleIdlType idl_type = 91001;
-
-  // Mark the non-optional() vector/array in idl.
-  optional int32 idl_on = 91002;
-
-  // Use this name as the field name for packing instead of the one in proto.
-  optional string idl_name = 91003;
-}
diff --git a/example/echo_c++_ubrpc_compack/server.cpp b/example/echo_c++_ubrpc_compack/server.cpp
deleted file mode 100644
index 23be57f..0000000
--- a/example/echo_c++_ubrpc_compack/server.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// A server to receive requests from ubrpc clients.
-// This server can be accessed by the client in public/baidu-rpc-ub/example/echo_c++_compack_ubrpc as well.
-
-#include <gflags/gflags.h>
-#include <butil/logging.h>
-#include <brpc/server.h>
-#include <brpc/policy/ubrpc2pb_protocol.h>
-#include "echo.pb.h"
-
-DEFINE_int32(port, 8500, "TCP Port of this server");
-DEFINE_int32(idle_timeout_s, -1, "Connection will be closed if there is no "
-             "read/write operations during the last `idle_timeout_s'");
-DEFINE_int32(logoff_ms, 2000, "Maximum duration of server's LOGOFF state "
-             "(waiting for client to close connection before server stops)");
-
-// Your implementation of EchoService
-namespace example {
-class EchoServiceImpl : public EchoService {
-public:
-    EchoServiceImpl() {};
-    virtual ~EchoServiceImpl() {};
-    virtual void Echo(google::protobuf::RpcController* cntl_base,
-                      const EchoRequest* request,
-                      EchoResponse* response,
-                      google::protobuf::Closure* done) {
-        // This object helps you to call done->Run() in RAII style. If you need
-        // to process the request asynchronously, pass done_guard.release().
-        brpc::ClosureGuard done_guard(done);
-        brpc::Controller* cntl =
-            static_cast<brpc::Controller*>(cntl_base);
-
-        LOG(INFO) << "Received request[log_id=" << cntl->log_id() 
-                  << "] from " << cntl->remote_side() 
-                  << " to " << cntl->local_side()
-                  << ": " << request->DebugString();
-
-        // Fill response.
-        response->set_message(request->message());
-        // the idl method returns void, no need to set_idl_result().
-    }
-
-    virtual void EchoWithMultiArgs(
-        google::protobuf::RpcController* cntl_base,
-        const MultiRequests* request,
-        MultiResponses* response,
-        google::protobuf::Closure* done) {
-        // This object helps you to call done->Run() in RAII style. If you need
-        // to process the request asynchronously, pass done_guard.release().
-        brpc::ClosureGuard done_guard(done);
-        brpc::Controller* cntl =
-            static_cast<brpc::Controller*>(cntl_base);
-
-        LOG(INFO) << "Received request[log_id=" << cntl->log_id() 
-                  << "] from " << cntl->remote_side() 
-                  << " to " << cntl->local_side()
-                  << ": req1=" << request->req1().message()
-                  << " req2=" << request->req2().message();
-
-        // Fill response.
-        response->mutable_res1()->set_message(request->req1().message());
-        response->mutable_res2()->set_message(request->req2().message());
-        // tell RPC that the idl method have more than one request/response.
-        cntl->set_idl_names(brpc::idl_multi_req_multi_res);
-        // the idl method returns uint32_t, we need to set it.
-        cntl->set_idl_result(17);
-    }
-};
-}  // namespace
-
-int main(int argc, char* argv[]) {
-    // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
-
-    // Generally you only need one Server.
-    brpc::Server server;
-
-    // Instance of your service.
-    example::EchoServiceImpl echo_service_impl;
-
-    // Add the service into server. Notice the second parameter, because the
-    // service is put on stack, we don't want server to delete it, otherwise
-    // use brpc::SERVER_OWNS_SERVICE.
-    if (server.AddService(&echo_service_impl, 
-                          brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
-        LOG(ERROR) << "Fail to add service";
-        return -1;
-    }
-
-    // Start the server.
-    brpc::ServerOptions options;
-    options.idle_timeout_sec = FLAGS_idle_timeout_s;
-    options.nshead_service = new brpc::policy::UbrpcCompackAdaptor;
-    if (server.Start(FLAGS_port, &options) != 0) {
-        LOG(ERROR) << "Fail to start EchoServer";
-        return -1;
-    }
-
-    // Wait until Ctrl-C is pressed, then Stop() and Join() the server.
-    server.RunUntilAskedToQuit();
-    return 0;
-}
diff --git a/example/grpc_c++/CMakeLists.txt b/example/grpc_c++/CMakeLists.txt
index 895dc8d..5f9032e 100644
--- a/example/grpc_c++/CMakeLists.txt
+++ b/example/grpc_c++/CMakeLists.txt
@@ -21,7 +21,7 @@ project(grpc_c++ C CXX)
 option(LINK_SO "Whether examples are linked dynamically" OFF)
 
 execute_process(
-    COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
+    COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
     OUTPUT_VARIABLE OUTPUT_PATH
 )
 
@@ -97,23 +97,24 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
+    ${THRIFT_LIB}
+    ${THRIFTNB_LIB}
     dl
     )
 
diff --git a/example/http_c++/CMakeLists.txt b/example/http_c++/CMakeLists.txt
index 132ec95..388b58c 100644
--- a/example/http_c++/CMakeLists.txt
+++ b/example/http_c++/CMakeLists.txt
@@ -108,23 +108,23 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/memcache_c++/CMakeLists.txt b/example/memcache_c++/CMakeLists.txt
index 90a37de..2554b82 100644
--- a/example/memcache_c++/CMakeLists.txt
+++ b/example/memcache_c++/CMakeLists.txt
@@ -102,23 +102,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/multi_threaded_echo_c++/CMakeLists.txt b/example/multi_threaded_echo_c++/CMakeLists.txt
index 617903b..c68010d 100644
--- a/example/multi_threaded_echo_c++/CMakeLists.txt
+++ b/example/multi_threaded_echo_c++/CMakeLists.txt
@@ -107,23 +107,23 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
@@ -143,8 +143,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
         "-Wl,-U,_ProfilerStop")
 endif()
 
-add_executable(multi_threaded_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
-add_executable(multi_threaded_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
+add_executable(echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
+add_executable(echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
+
+target_link_libraries(echo_client ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
+target_link_libraries(echo_server ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
 
-target_link_libraries(multi_threaded_echo_client ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
-target_link_libraries(multi_threaded_echo_server ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
+file(COPY ${PROJECT_SOURCE_DIR}/key.pem
+     DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY ${PROJECT_SOURCE_DIR}/cert.pem
+     DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/example/multi_threaded_echo_fns_c++/CMakeLists.txt b/example/multi_threaded_echo_fns_c++/CMakeLists.txt
index 3c7ee08..148490a 100644
--- a/example/multi_threaded_echo_fns_c++/CMakeLists.txt
+++ b/example/multi_threaded_echo_fns_c++/CMakeLists.txt
@@ -107,23 +107,23 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/multi_threaded_mcpack_c++/CMakeLists.txt b/example/multi_threaded_mcpack_c++/CMakeLists.txt
deleted file mode 100644
index 7454e38..0000000
--- a/example/multi_threaded_mcpack_c++/CMakeLists.txt
+++ /dev/null
@@ -1,155 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-cmake_minimum_required(VERSION 2.8.10)
-project(multi_threaded_mcpack_c++ C CXX)
-
-option(LINK_SO "Whether examples are linked dynamically" OFF)
-
-execute_process(
-    COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
-    OUTPUT_VARIABLE OUTPUT_PATH
-)
-
-set(CMAKE_PREFIX_PATH ${OUTPUT_PATH})
-
-include(FindThreads)
-include(FindProtobuf)
-protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
-# include PROTO_HEADER
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# Search for libthrift* by best effort. If it is not found and brpc is
-# compiled with thrift protocol enabled, a link error would be reported.
-find_library(THRIFT_LIB NAMES thrift)
-if (NOT THRIFT_LIB)
-    set(THRIFT_LIB "")
-endif()
-find_library(THRIFTNB_LIB NAMES thriftnb)
-if (NOT THRIFTNB_LIB)
-    set(THRIFTNB_LIB "")
-endif()
-
-find_path(GPERFTOOLS_INCLUDE_DIR NAMES gperftools/heap-profiler.h)
-find_library(GPERFTOOLS_LIBRARIES NAMES tcmalloc_and_profiler)
-include_directories(${GPERFTOOLS_INCLUDE_DIR})
-
-find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
-if(LINK_SO)
-    find_library(BRPC_LIB NAMES brpc)
-else()
-    find_library(BRPC_LIB NAMES libbrpc.a brpc)
-endif()
-if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB))
-    message(FATAL_ERROR "Fail to find brpc")
-endif()
-include_directories(${BRPC_INCLUDE_PATH})
-
-find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h)
-find_library(GFLAGS_LIBRARY NAMES gflags libgflags)
-if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
-    message(FATAL_ERROR "Fail to find gflags")
-endif()
-include_directories(${GFLAGS_INCLUDE_PATH})
-
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    include(CheckFunctionExists)
-    CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
-    if(NOT HAVE_CLOCK_GETTIME)
-        set(DEFINE_CLOCK_GETTIME "-DNO_CLOCK_GETTIME_IN_MAC")
-    endif()
-endif()
-
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
-
-if(CMAKE_VERSION VERSION_LESS "3.1.3")
-    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-    endif()
-    if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-    endif()
-else()
-    set(CMAKE_CXX_STANDARD 11)
-    set(CMAKE_CXX_STANDARD_REQUIRED ON)
-endif()
-
-find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h)
-find_library(LEVELDB_LIB NAMES leveldb)
-if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
-    message(FATAL_ERROR "Fail to find leveldb")
-endif()
-include_directories(${LEVELDB_INCLUDE_PATH})
-
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
-endif()
-
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
-
-set(DYNAMIC_LIB
-    ${CMAKE_THREAD_LIBS_INIT}
-    ${GFLAGS_LIBRARY}
-    ${PROTOBUF_LIBRARIES}
-    ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
-    ${THRIFT_LIB}
-    ${THRIFTNB_LIB}
-    dl
-    )
-
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    set(DYNAMIC_LIB ${DYNAMIC_LIB}
-        pthread
-        "-framework CoreFoundation"
-        "-framework CoreGraphics"
-        "-framework CoreData"
-        "-framework CoreText"
-        "-framework Security"
-        "-framework Foundation"
-        "-Wl,-U,_MallocExtension_ReleaseFreeMemory"
-        "-Wl,-U,_ProfilerStart"
-        "-Wl,-U,_ProfilerStop")
-endif()
-
-execute_process(
-    COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${PROJECT_SOURCE_DIR} --plugin=protoc-gen-mcpack=${OUTPUT_PATH}/bin/protoc-gen-mcpack --mcpack_out=${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/echo.proto
-	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-add_executable(multi_threaded_mcpack_client client.cpp ${CMAKE_CURRENT_BINARY_DIR}/echo.pb.cc)
-add_executable(multi_threaded_mcpack_server server.cpp ${CMAKE_CURRENT_BINARY_DIR}/echo.pb.cc)
-
-target_link_libraries(multi_threaded_mcpack_client ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
-target_link_libraries(multi_threaded_mcpack_server ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
diff --git a/example/multi_threaded_mcpack_c++/Makefile b/example/multi_threaded_mcpack_c++/Makefile
deleted file mode 100644
index a56e5d1..0000000
--- a/example/multi_threaded_mcpack_c++/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-PROTOC_EXTRA_ARGS = --plugin=protoc-gen-mcpack=$(BRPC_PATH)/output/bin/protoc-gen-mcpack --proto_path=$(BRPC_PATH)/output/include --proto_path=$(PROTOBUF_HDR) --mcpack_out=. 
-include ../multi_threaded_echo_c++/Makefile
diff --git a/example/multi_threaded_mcpack_c++/client.cpp b/example/multi_threaded_mcpack_c++/client.cpp
deleted file mode 100644
index 7f0dc54..0000000
--- a/example/multi_threaded_mcpack_c++/client.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// A client sending requests to server by multiple threads.
-
-#include <gflags/gflags.h>
-#include <bthread/bthread.h>
-#include <butil/logging.h>
-#include <brpc/server.h>
-#include <brpc/channel.h>
-#include "echo.pb.h"
-#include <bvar/bvar.h>
-
-DEFINE_int32(thread_num, 50, "Number of threads to send requests");
-DEFINE_bool(use_bthread, false, "Use bthread to send requests");
-DEFINE_int32(attachment_size, 0, "Carry so many byte attachment along with requests");
-DEFINE_int32(request_size, 16, "Bytes of each request");
-DEFINE_string(server, "0.0.0.0:8002", "IP Address of server");
-DEFINE_string(load_balancer, "", "The algorithm for load balancing");
-DEFINE_int32(timeout_ms, 100, "RPC timeout in milliseconds");
-DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); 
-DEFINE_bool(dont_fail, false, "Print fatal when some call failed");
-DEFINE_int32(dummy_port, -1, "Launch dummy server at this port");
-
-std::string g_request;
-std::string g_attachment;
-
-bvar::LatencyRecorder g_latency_recorder("client");
-bvar::Adder<int> g_error_count("client_error_count");
-
-static void* sender(void* arg) {
-    // Normally, you should not call a Channel directly, but instead construct
-    // a stub Service wrapping it. stub can be shared by all threads as well.
-    example::EchoService_Stub stub(static_cast<google::protobuf::RpcChannel*>(arg));
-
-    int log_id = 0;
-    example::EchoRequest request;
-    example::EchoResponse response;
-    brpc::Controller cntl;
-    while (!brpc::IsAskedToQuit()) {
-        // We will receive response synchronously, safe to put variables
-        // on stack.
-        request.Clear();
-        response.Clear();
-        cntl.Reset();
-
-        request.set_message(g_request);
-        cntl.set_log_id(log_id++);  // set by user
-        if (!g_attachment.empty()) {
-            // Set attachment which is wired to network directly instead of 
-            // being serialized into protobuf messages.
-            cntl.request_attachment().append(g_attachment);
-        }
-
-        // Because `done'(last parameter) is NULL, this function waits until
-        // the response comes back or error occurs(including timedout).
-        stub.Echo(&cntl, &request, &response, NULL);
-        if (!cntl.Failed()) {
-            g_latency_recorder << cntl.latency_us();
-        } else {
-            g_error_count << 1; 
-            CHECK(brpc::IsAskedToQuit() || !FLAGS_dont_fail)
-                << "error=" << cntl.ErrorText() << " latency=" << cntl.latency_us();
-            // We can't connect to the server, sleep a while. Notice that this
-            // is a specific sleeping to prevent this thread from spinning too
-            // fast. You should continue the business logic in a production 
-            // server rather than sleeping.
-            bthread_usleep(50000);
-        }
-    }
-    return NULL;
-}
-
-int main(int argc, char* argv[]) {
-    // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
-
-    // A Channel represents a communication line to a Server. Notice that 
-    // Channel is thread-safe and can be shared by all threads in your program.
-    brpc::Channel channel;
-    
-    // Initialize the channel, NULL means using default options.
-    brpc::ChannelOptions options;
-    options.protocol = "nshead_mcpack";
-    options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/;
-    options.max_retry = FLAGS_max_retry;
-    if (channel.Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) {
-        LOG(ERROR) << "Fail to initialize channel";
-        return -1;
-    }
-
-    if (FLAGS_attachment_size > 0) {
-        g_attachment.resize(FLAGS_attachment_size, 'a');
-    }
-    if (FLAGS_request_size <= 0) {
-        LOG(ERROR) << "Bad request_size=" << FLAGS_request_size;
-        return -1;
-    }
-    g_request.resize(FLAGS_request_size, 'r');
-
-    if (FLAGS_dummy_port >= 0) {
-        brpc::StartDummyServerAt(FLAGS_dummy_port);
-    }
-
-    std::vector<bthread_t> bids;
-    std::vector<pthread_t> pids;
-    if (!FLAGS_use_bthread) {
-        pids.resize(FLAGS_thread_num);
-        for (int i = 0; i < FLAGS_thread_num; ++i) {
-            if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
-                LOG(ERROR) << "Fail to create pthread";
-                return -1;
-            }
-        }
-    } else {
-        bids.resize(FLAGS_thread_num);
-        for (int i = 0; i < FLAGS_thread_num; ++i) {
-            if (bthread_start_background(
-                    &bids[i], NULL, sender, &channel) != 0) {
-                LOG(ERROR) << "Fail to create bthread";
-                return -1;
-            }
-        }
-    }
-
-    while (!brpc::IsAskedToQuit()) {
-        sleep(1);
-        LOG(INFO) << "Sending requests at qps=" << g_latency_recorder.qps(1)
-                  << " latency=" << g_latency_recorder.latency(1);
-    }
-
-    LOG(INFO) << "EchoClient is going to quit";
-    for (int i = 0; i < FLAGS_thread_num; ++i) {
-        if (!FLAGS_use_bthread) {
-            pthread_join(pids[i], NULL);
-        } else {
-            bthread_join(bids[i], NULL);
-        }
-    }
-
-    return 0;
-}
diff --git a/example/multi_threaded_mcpack_c++/echo.proto b/example/multi_threaded_mcpack_c++/echo.proto
deleted file mode 100644
index 85e5b88..0000000
--- a/example/multi_threaded_mcpack_c++/echo.proto
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// Converted from echo.idl by brpc/tools/idl2proto
-syntax="proto2";
-import "idl_options.proto";
-option (idl_support) = true;
-option cc_generic_services = true;
-
-package example;
-
-message EchoRequest {
-    optional string message = 1;
-}
-
-message EchoResponse {
-    optional string message = 1; 
-}
-
-service EchoService {
-    rpc Echo(EchoRequest) returns (EchoResponse);
-}
diff --git a/example/multi_threaded_mcpack_c++/idl_options.proto b/example/multi_threaded_mcpack_c++/idl_options.proto
deleted file mode 100644
index 5687699..0000000
--- a/example/multi_threaded_mcpack_c++/idl_options.proto
+++ /dev/null
@@ -1,54 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-syntax="proto2";
-// mcpack2pb - Make protobuf be front-end of mcpack/compack
-
-import "google/protobuf/descriptor.proto";
-
-extend google.protobuf.FileOptions {
-  // True to generate mcpack parsing/serializing code
-  optional bool idl_support = 91000;
-}
-
-enum ConvertibleIdlType {
-  IDL_AUTO = 0;
-  IDL_INT8 = 1;
-  IDL_INT16 = 2;
-  IDL_INT32 = 3;
-  IDL_INT64 = 4;
-  IDL_UINT8 = 5;
-  IDL_UINT16 = 6;
-  IDL_UINT32 = 7;
-  IDL_UINT64 = 8;
-  IDL_BOOL = 9;
-  IDL_FLOAT = 10;
-  IDL_DOUBLE = 11;
-  IDL_BINARY = 12;
-  IDL_STRING = 13;
-}
-
-extend google.protobuf.FieldOptions {
-  // Mark the idl-type which is inconsistent with proto-type.
-  optional ConvertibleIdlType idl_type = 91001;
-
-  // Mark the non-optional() vector/array in idl.
-  optional int32 idl_on = 91002;
-
-  // Use this name as the field name for packing instead of the one in proto.
-  optional string idl_name = 91003;
-}
diff --git a/example/multi_threaded_mcpack_c++/server.cpp b/example/multi_threaded_mcpack_c++/server.cpp
deleted file mode 100644
index 43d2ba9..0000000
--- a/example/multi_threaded_mcpack_c++/server.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// A server to receive EchoRequest and send back EchoResponse.
-
-#include <gflags/gflags.h>
-#include <butil/logging.h>
-#include <brpc/server.h>
-#include <brpc/policy/nshead_mcpack_protocol.h>
-#include "echo.pb.h"
-
-DEFINE_int32(port, 8002, "TCP Port of this server");
-DEFINE_int32(idle_timeout_s, -1, "Connection will be closed if there is no "
-             "read/write operations during the last `idle_timeout_s'");
-DEFINE_int32(logoff_ms, 2000, "Maximum duration of server's LOGOFF state "
-             "(waiting for client to close connection before server stops)");
-DEFINE_int32(max_concurrency, 0, "Limit of request processing in parallel");
-DEFINE_int32(internal_port, -1, "Only allow builtin services at this port");
-
-namespace example {
-// Your implementation of EchoService
-class EchoServiceImpl : public EchoService {
-public:
-    EchoServiceImpl() {}
-    ~EchoServiceImpl() {};
-    void Echo(google::protobuf::RpcController* cntl_base,
-              const EchoRequest* request,
-              EchoResponse* response,
-              google::protobuf::Closure* done) {
-        brpc::ClosureGuard done_guard(done);
-        response->set_message(request->message());
-    }
-};
-}  // namespace example
-
-int main(int argc, char* argv[]) {
-    // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
-
-    // Generally you only need one Server.
-    brpc::Server server;
-
-    // Instance of your service.
-    example::EchoServiceImpl echo_service_impl;
-
-    // Add the service into server. Notice the second parameter, because the
-    // service is put on stack, we don't want server to delete it, otherwise
-    // use brpc::SERVER_OWNS_SERVICE.
-    if (server.AddService(&echo_service_impl, 
-                          brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
-        LOG(ERROR) << "Fail to add service";
-        return -1;
-    }
-
-    // Start the server. 
-    brpc::ServerOptions options;
-    options.idle_timeout_sec = FLAGS_idle_timeout_s;
-    options.nshead_service = new brpc::policy::NsheadMcpackAdaptor;
-    options.max_concurrency = FLAGS_max_concurrency;
-    options.internal_port = FLAGS_internal_port;
-    if (server.Start(FLAGS_port, &options) != 0) {
-        LOG(ERROR) << "Fail to start EchoServer";
-        return -1;
-    }
-
-    // Wait until Ctrl-C is pressed, then Stop() and Join() the server.
-    server.RunUntilAskedToQuit();
-    return 0;
-}
diff --git a/example/nshead_extension_c++/CMakeLists.txt b/example/nshead_extension_c++/CMakeLists.txt
index 73d53dd..72c9b41 100644
--- a/example/nshead_extension_c++/CMakeLists.txt
+++ b/example/nshead_extension_c++/CMakeLists.txt
@@ -102,23 +102,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/nshead_pb_extension_c++/CMakeLists.txt b/example/nshead_pb_extension_c++/CMakeLists.txt
index 65e34a2..82c055b 100644
--- a/example/nshead_pb_extension_c++/CMakeLists.txt
+++ b/example/nshead_pb_extension_c++/CMakeLists.txt
@@ -102,23 +102,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/parallel_echo_c++/CMakeLists.txt b/example/parallel_echo_c++/CMakeLists.txt
index bbf7900..65b2515 100644
--- a/example/parallel_echo_c++/CMakeLists.txt
+++ b/example/parallel_echo_c++/CMakeLists.txt
@@ -107,23 +107,23 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/partition_echo_c++/CMakeLists.txt b/example/partition_echo_c++/CMakeLists.txt
index cd6adbc..fecdfa0 100644
--- a/example/partition_echo_c++/CMakeLists.txt
+++ b/example/partition_echo_c++/CMakeLists.txt
@@ -107,23 +107,23 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/redis_c++/CMakeLists.txt b/example/redis_c++/CMakeLists.txt
index b1e0f77..f1bafec 100644
--- a/example/redis_c++/CMakeLists.txt
+++ b/example/redis_c++/CMakeLists.txt
@@ -111,23 +111,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     ${GPERFTOOLS_LIBRARIES}
diff --git a/example/selective_echo_c++/CMakeLists.txt b/example/selective_echo_c++/CMakeLists.txt
index 7e5025a..7413528 100644
--- a/example/selective_echo_c++/CMakeLists.txt
+++ b/example/selective_echo_c++/CMakeLists.txt
@@ -107,23 +107,23 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/session_data_and_thread_local/CMakeLists.txt b/example/session_data_and_thread_local/CMakeLists.txt
index 7301cd2..120f92e 100644
--- a/example/session_data_and_thread_local/CMakeLists.txt
+++ b/example/session_data_and_thread_local/CMakeLists.txt
@@ -114,23 +114,17 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl
diff --git a/example/streaming_echo_c++/CMakeLists.txt b/example/streaming_echo_c++/CMakeLists.txt
index 3ea83c6..57fe261 100644
--- a/example/streaming_echo_c++/CMakeLists.txt
+++ b/example/streaming_echo_c++/CMakeLists.txt
@@ -102,23 +102,22 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
 endif()
 include_directories(${LEVELDB_INCLUDE_PATH})
 
-find_library(SSL_LIB NAMES ssl)
-if (NOT SSL_LIB)
-    message(FATAL_ERROR "Fail to find ssl")
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set(OPENSSL_ROOT_DIR
+        "/usr/local/opt/openssl"    # Homebrew installed OpenSSL
+        )
 endif()
 
-find_library(CRYPTO_LIB NAMES crypto)
-if (NOT CRYPTO_LIB)
-    message(FATAL_ERROR "Fail to find crypto")
-endif()
+find_package(OpenSSL)
+include_directories(${OPENSSL_INCLUDE_DIR})
 
 set(DYNAMIC_LIB
     ${CMAKE_THREAD_LIBS_INIT}
     ${GFLAGS_LIBRARY}
     ${PROTOBUF_LIBRARIES}
     ${LEVELDB_LIB}
-    ${SSL_LIB}
-    ${CRYPTO_LIB}
+    ${OPENSSL_CRYPTO_LIBRARY}
+    ${OPENSSL_SSL_LIBRARY}
     ${THRIFT_LIB}
     ${THRIFTNB_LIB}
     dl


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org