google / s2geometry

Computational geometry and spatial indexing on the sphere
http://s2geometry.io/
Apache License 2.0
2.29k stars 302 forks source link

build fail with error on Ubuntu20.04 #365

Open kusa-dowsing opened 3 months ago

kusa-dowsing commented 3 months ago

version: master

os: wsl2 ubuntu20.04

cmake option: cmake -DCMAKE_CXX_STANDARD=17 -DWITH_GFLAGS=ON -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCMAKE_INSTALL_LIBDIR=${INSTALL_DIR}/lib ..

error: call to non-‘constexpr’ function /s2geometry/src/s2/s1chord_angle.h:311:43: error: call to non-‘constexpr’ function ‘T util::math::internal_vector::BasicVector<VecTemplate, T, N>::Norm2() const [with VecTemplate = Vector3; T = double; long unsigned int N = 3]’ /s2geometry/src/s2/s1chord_angle.h:311:43: error: call to non-‘constexpr’ function ‘T util::math::internal_vector::BasicVector<VecTemplate, T, N>::Norm2() const [with VecTemplate = Vector3; T = double; long unsigned int N = 3]’ s2geometry/src/s2/s1chord_angle.h:311:43: error: call to non-‘constexpr’ function ‘T util::math::internal_vector::BasicVector<VecTemplate, T, N>::Norm2() const [with VecTemplate = Vector3; T = double; long unsigned int N = 3]’

screenshot-20240523-161927

jmr commented 3 months ago

Thanks for the report. We already fixed this in the internal version by removing constexpr from a bunch of functions. I'll do a new code push in the next few weeks.

kusa-dowsing commented 3 months ago

Thanks for the report. We already fixed this in the internal version by removing constexpr from a bunch of functions. I'll do a new code push in the next few weeks.

A New Error was occurred. after i removed the constexpr, i built the lib successfully. But when i used the s2 lib, i got A new Error, like: /home/tsh/workspace/auto_pro/modules/cmake_modules/../../third_party/x86_64/include/s2/base/log_severity.h:27:16: error: ‘constexpr const bool google::DEBUG_MODE’ redeclared as different kind of entity 27 | constexpr bool DEBUG_MODE = true; | ^~~~~~ In file included from /usr/include/glog/logging.h:512, from /home/tsh/workspace/auto_pro/opt/include/openads/modules/ads_common/common/ulog.h:30, from /home/tsh/workspace/auto_pro/opt/include/openads/modules/ads_common/common/environment.h:25, from /home/tsh/workspace/auto_pro/modules/applications/ped_trick/src/geo_trajectory.h:6, from /home/tsh/workspace/auto_pro/modules/applications/ped_trick/src/geo_trajectory.cc:1: /usr/include/glog/log_severity.h:88:8: note: previous declaration ‘google:: google::DEBUG_MODE’ 88 | enum { DEBUG_MODE = 1 };

image it looks like the s2geometry need the specified version of glog, but i don't know which version would be used for s2, can you show me the right one?

jmr commented 3 months ago
In file included from /usr/include/glog/logging.h:512,
from /home/tsh/workspace/auto_pro/opt/include/openads/modules/ads_common/common/ulog.h:30,

We don't use glog anymore. Can you switch to abseil-cpp logging?

S2 should not be defining google::DEBUG_MODE, though. I guess we should call it S2_DEBUG_MODE.

kusa-dowsing commented 3 months ago
In file included from /usr/include/glog/logging.h:512,
from /home/tsh/workspace/auto_pro/opt/include/openads/modules/ads_common/common/ulog.h:30,

We don't use glog anymore. Can you switch to abseil-cpp logging?

S2 should not be defining google::DEBUG_MODE, though. I guess we should call it S2_DEBUG_MODE.

may be you wanna be compatible with glog? image

jmr commented 3 months ago

The comment is now wrong and this definition is making us incompatible with glog.

Mechree commented 2 months ago

version: master

os: wsl2 ubuntu20.04

cmake option: cmake -DCMAKE_CXX_STANDARD=17 -DWITH_GFLAGS=ON -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCMAKE_INSTALL_LIBDIR=${INSTALL_DIR}/lib ..

error: call to non-‘constexpr’ function /s2geometry/src/s2/s1chord_angle.h:311:43: error: call to non-‘constexpr’ function ‘T util::math::internal_vector::BasicVector<VecTemplate, T, N>::Norm2() const [with VecTemplate = Vector3; T = double; long unsigned int N = 3]’ /s2geometry/src/s2/s1chord_angle.h:311:43: error: call to non-‘constexpr’ function ‘T util::math::internal_vector::BasicVector<VecTemplate, T, N>::Norm2() const [with VecTemplate = Vector3; T = double; long unsigned int N = 3]’ s2geometry/src/s2/s1chord_angle.h:311:43: error: call to non-‘constexpr’ function ‘T util::math::internal_vector::BasicVector<VecTemplate, T, N>::Norm2() const [with VecTemplate = Vector3; T = double; long unsigned int N = 3]’

screenshot-20240523-161927

Hey, I ran into the same issue, and it turned out that the G++ is incompatible with s2geometry. After switching to the Clang compiler, I was able to successfully build and install s2geometry. I had to specify the compiler in the cmake command:

cmake -DWITH_GFLAGS=ON -DWITH_GTEST=ON \
-DGOOGLETEST_ROOT=/home/user/myvenv/Source/googletest \
-DOPENSSL_INCLUDE_DIR=/usr/lib/ssl \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_CXX_COMPILER=clang++ ..
jmr commented 2 months ago

Could you try with #367 ?