Skip to content

Commit

Permalink
Elaborate how-to-build steps for MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesge committed Jun 8, 2022
1 parent efa9989 commit 9556320
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
28 changes: 17 additions & 11 deletions docs/cn/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ $ make

注意:在相同硬件条件下,MacOS版brpc的性能可能明显差于Linux版。如果你的服务是性能敏感的,请不要使用MacOS作为你的生产环境。

### Apple Silicon

master HEAD已支持M1系列芯片,M2未测试过。欢迎通过issues向我们报告遗留的warning/error。

### 依赖准备

安装依赖:
Expand All @@ -225,29 +229,31 @@ brew install openssl git gnu-getopt coreutils gflags protobuf leveldb
brew install gperftools
```

如果你要运行测试,那么要安装并编译googletest(它没有被默认编译)
如果你要运行测试,需安装gtest。先运行`brew install googletest`看看homebrew是否支持(老版本没有),没有的话请下载和编译googletest
```shell
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
```
在编译完成后,复制include/和lib/目录到/usr/local/include和/usr/local/lib目录中,以便于让所有应用都能使用gtest。

### Monterey
Monterey中openssl的安装位置可能不再位于`/usr/local/opt/openssl`,很可能会在`/opt/homebrew/Cellar`目录下,如果编译时报告找不到openssl,可考虑设置软链如下:
```shell
sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 /usr/local/opt/openssl
```
请注意上述命令中openssl的目录可能随环境变化而变化,你可以通过`brew info openssl`查看。
在编译完成后,复制`include/``lib/`目录到`/usr/local/include``/usr/local/lib`目录中,以便于让所有应用都能使用gtest。

### Apple Silicon
### OpenSSL
Monterey中openssl的安装位置可能不再位于`/usr/local/opt/openssl`,很可能会在`/opt/homebrew/Cellar`目录下,如果编译时报告找不到openssl:

master HEAD已支持M1系列芯片,M2未测试过。欢迎通过issues向我们报告遗留的warning/error。
* 先运行`brew link openssl --force`看看`/user/local/opt/openssl`是否出现了
* 没有的话可以自行设置软链:`sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 /usr/local/opt/openssl`。请注意此命令中openssl的目录可能随环境变化而变化,可通过`brew info openssl`查看。

### 使用config_brpc.sh编译brpc
git克隆brpc,进入到项目目录然后运行:
```shell
$ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=clang --cxx=clang++
$ make
```
MacOS Monterey下的brew安装路径可能改变,如有路径相关的错误,可考虑设置如下:

```shell
$ sh config_brpc.sh --headers=/opt/homebrew/include --libs=/opt/homebrew/lib --cc=clang --cxx=clang++
$ make
```

不想链接调试符号,添加选项`--nodebugsymbols`,然后编译将会得到更轻量的二进制文件。

使用glog版的brpc,添加选项`--with-glog`
Expand Down
31 changes: 18 additions & 13 deletions docs/en/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ Same with [here](#compile-brpc-with-cmake)

Note: With same environment, the performance of the MacOS version is worse than the Linux version. If your service is performance-critical, do not use MacOS as your production environment.

### Apple Silicon

The code at master HEAD already supports M1 series chips. M2 series are not tested yet. Please feel free to report remaining warnings/errors to us by issues.

### Prepare deps

Install dependencies:
Expand All @@ -229,32 +233,33 @@ If you need to enable cpu/heap profilers in examples:
brew install gperftools
```

If you need to run tests, download and compile googletest (which is not compiled yet):
If you need to run tests, googletest is required. Run `brew install googletest` first to see if it works. If not (old homebrew does not have googletest), you can download and compile googletest by your own:
```shell
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
After the compilation, copy `include/` and `lib/` into `/usr/local/include` and `/usr/local/lib` respectively to expose gtest to all apps

### Monterey
### OpenSSL

openssl installed in Monterey may not be found at `/usr/local/opt/openssl`, instead it's probably put under `/opt/homebrew/Cellar`. If the compiler cannot find openssl, consider making a soft link like below:
openssl installed in Monterey may not be found at `/usr/local/opt/openssl`, instead it's probably put under `/opt/homebrew/Cellar`. If the compiler cannot find openssl

```shell
sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 /usr/local/opt/openssl
```

Please note that the directory of installed openssl in above command may be different in different environments, you could check it out by running `brew info openssl`.

### Apple Silicon

The code at master HEAD already supports M1 series chips. M2 series are not tested yet. Please feel free to report remaining warnings/errors to us by issues.
* Run `brew link openssl --force` first and check if `/user/local/opt/openssl` appears.
* If above command does not work, consider making a soft link using `sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 /usr/local/opt/openssl`. Note that the installed openssl in above command may be put in different places in different environments, which could be revealed by running `brew info openssl`.

### Compile brpc with config_brpc.sh
git clone brpc, cd into the repo and run
```shell
$ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=clang --cxx=clang++
$ make
```

The homebrew in Monterey may install software at different directories from before. If path related errors are reported, try setting headers/libs like below:

```shell
$ sh config_brpc.sh --headers=/opt/homebrew/include --libs=/opt/homebrew/lib --cc=clang --cxx=clang++
$ make
```

To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.

To use brpc with glog, add `--with-glog`.
Expand Down

0 comments on commit 9556320

Please sign in to comment.