s2geometry mac 编译

编译的具体过程可以参照官方git:https://github.com/google/s2geometry

准备

环境准备环节需要注意以下两点:

  1. gtest库下载源码解压即可,在编译时通过设置gtest源码路径链接。
  2. openssl直接使用brew或者macport安装的不可以,需要下载源码自行编译安装。

Build and install

git clone

cd [parent of directory where you want to put S2]
git clone https://github.com/google/s2geometry.git
cd s2geometry

Building

From the appropriate directory depending on how you got the source:

mkdir build
cd build
# You can omit -DGTEST_ROOT to skip tests; see above for macOS.
cmake -DGTEST_ROOT=/usr/src/gtest ..
make
make test  # If GTEST_ROOT specified above.
sudo make install

Enable gflags and glog with cmake -DWITH_GFLAGS=ON -DWITH_GLOG=ON ....

Disable building of shared libraries with -DBUILD_SHARED_LIBS=OFF.

在build的环节可能遇到以下两个问题:

  1. 执行cmake ..时可能会提示找不到openssl库
  2. 执行make提示啥啥错误(忘记啥错误了,复现不出来了)
    解决:在cmake时指定openssl的位置,并且将编译器切换成gcc。
cmake -DCMAKE_C_COMPILER="/usr/bin/gcc" \
-DCMAKE_CXX_COMPILER="/usr/bin/g++"  \
-DOPENSSL_INCLUDE_DIR="/usr/local/include/" \ 
-DOPENSSL_SSL_LIBRARY=/usr/local/lib/libssl.a \ 
-DGTEST_ROOT=/Users/df/Projects/googletest-release-1.8.0/googletest ..
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容