Skip to content

Instantly share code, notes, and snippets.

@missinglink
Last active September 8, 2021 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save missinglink/78dcb118f9a7566afe98d1a2c9d05d5f to your computer and use it in GitHub Desktop.
Save missinglink/78dcb118f9a7566afe98d1a2c9d05d5f to your computer and use it in GitHub Desktop.
install s2geometry (c++ libs) on mac with brew / plus hello world s2geometry example
# based on: https://s2geometry.io/about/platforms
# note: set -DOPENSSL_ROOT_DIR instead of -DOPENSSL_INCLUDE_DIR
brew install gflags glog openssl
brew install cmake
# Download Googletest release 1.8.0 and unpack it in a directory of your choosing.
# (Take note of this directory as you will need to point CMake to it.)
# https://github.com/google/googletest/releases/tag/release-1.8.0
# find where brew installed openssl (such as /usr/local/Cellar/openssl@1.1/1.1.1l)
# maybe use: brew --prefix openssl
git clone git@github.com:google/s2geometry.git
cd s2geometry
mkdir build
cd build
cmake \
-DWITH_GFLAGS=ON \
-WITH_GTEST=ON \
-DGTEST_ROOT=/code/google/googletest/googletest-release-1.8.0/googletest \
-DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl@1.1/1.1.1l \
..
make -j8
make install
#include "s2/s2point.h"
#include "s2/s2cell_id.h"
using namespace std;
int main()
{
S2Point v0 = S2Point(1, 1, 0);
cout<<v0<<endl;
S2CellId id = S2CellId(v0);
cout<<id<<endl;
return 0;
}
CXX=g++
CXXFLAGS=-std=c++11 -stdlib=libc++
LDLIBS=-ls2
OBJS=main.cpp
build: $(OBJS)
$(CXX) $(LDLIBS) $(CXXFLAGS) -o app $(OBJS)
run: build
./app
make run
g++ -ls2 -std=c++11 -stdlib=libc++ -o app main.cpp
./app
[1, 1, 0]
1/322222222222222222222222222222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment