编译的具体过程可以参照官方git:https://github.com/google/s2geometry
准备
- CMake
- A C++ compiler with C++11 support, such as g++ >= 4.7.
- OpenSSL (for its bignum library)
- gflags command line flags, optional
- glog logging module, optional
- googletest testing framework (to build tests and example programs, optional)
环境准备环节需要注意以下两点:
- gtest库下载源码解压即可,在编译时通过设置gtest源码路径链接。
- 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的环节可能遇到以下两个问题:
- 执行
cmake ..
时可能会提示找不到openssl库 - 执行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 ..
网友评论