Commit ee458c7c authored by zhujiashun's avatar zhujiashun

Add build docs for macos

parent 8e8fd83d
......@@ -11,6 +11,7 @@
*.pb.h
*.prof
*.so
*.dylib
/output
/test/output
......
SYSTEM=$(uname -s)
if [ "$SYSTEM" = "Darwin" ]; then
ECHO='echo -e'
ECHO='echo'
SO=dylib
LDD="otool -L"
if [ "$(getopt -V)" = " --" ]; then
......
......@@ -8,6 +8,13 @@ brpc depends on following packages:
* [protobuf](https://github.com/google/protobuf): Serializations of messages, interfaces of services.
* [leveldb](https://github.com/google/leveldb): Required by [/rpcz](rpcz.md) to record RPCs for tracing.
# Supported System
* [Ubuntu/LinuxMint/WSL](#ubuntu/linuxmint/wsl)
* [Fedora/CentOS](#fedora/centos)
* [Linux with self-built deps](#linux-with-self-built-deps)
* [MacOS](#macos)
## Ubuntu/LinuxMint/WSL
### Prepare deps
......@@ -210,6 +217,75 @@ To change compiler to clang, overwrite environment variable CC and CXX to clang
To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
## MacOS
### Prepare deps
Install common deps:
```
$ brew install openssl git
```
Install [gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb):
```
$ brew install gflags protobuf leveldb
```
### Compile brpc with config_brpc.sh
git clone brpc, cd into the repo and run
```
$ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=gcc --cxx=clang++
$ make
```
To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.
**Run example**
```
$ cd example/echo_c++
$ make
$ ./echo_server &
$ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, `make clean` and `LINK_SO=1 make`
To run examples with cpu/heap profilers, install `gperftools` and re-run `config_brpc.sh` before compiling.
**Run tests**
Install and compile googletest (which is not compiled yet):
```shell
git clone https://github.com/google/googletest && cd googletest/googletest && mkdir build && cd build && cmake .. && make && sudo mv libgtest* /usr/lib/ && cd -
```
Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh`
### Compile brpc with cmake
```
$ mkdir build && cd build && cmake .. && make
```
To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
**Run example with cmake**
```
$ cd example/echo_c++
$ mkdir build && cd build && cmake .. && make
$ ./echo_server &
$ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, use `cmake -DEXAMPLE_LINK_SO=ON ..`
**Run tests**
Install gtest like just written above.
```
$ mkdir build && cd build && cmake -DBUILD_UNIT_TESTS=ON .. && make
$ cd test && sh run_tests.sh
```
# Supported deps
## GCC: 4.8-7.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment