s2geometry
s2geometry copied to clipboard
ld: symbol(s) not found for architecture x86_64
As per the installation guidlines,facing an error at last step make:
[ 1%] Built target gtest [ 2%] Built target s2testing [ 3%] Linking CXX shared library libs2.dylib Undefined symbols for architecture x86_64: "_BN_bn2lebinpad", referenced from: BN_ext_count_low_zero_bits(bignum_st const*) in exactfloat.cc.o "_BN_is_negative", referenced from: ExactFloat::SignedSum(int, ExactFloat const*, int, ExactFloat const*) in exactfloat.cc.o "_BN_is_odd", referenced from: ExactFloat::Canonicalize() in exactfloat.cc.o "_BN_is_zero", referenced from: ExactFloat::set_nan() in exactfloat.cc.o ExactFloat::set_inf(int) in exactfloat.cc.o ExactFloat::Canonicalize() in exactfloat.cc.o ExactFloat::set_zero(int) in exactfloat.cc.o ExactFloat::SignedSum(int, ExactFloat const*, int, ExactFloat const*) in exactfloat.cc.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [libs2.dylib] Error 1 make[1]: *** [CMakeFiles/s2.dir/all] Error 2 make: *** [all] Error 2
I had this problem on macOS Catalina 10.15.6, using OpenSSL 1.1.1g installed from Homebrew. (BTW, @Razi007, this would have been helpful to the project's developers to include in your initial report! 😃 )
It looks like the instructions are wrong. I resolved this issue by using -DOPENSSL_ROOT_DIR
to specify the OpenSSL install location, rather than -DOPENSSL_INCLUDE_DIR
(which would still try to link against /usr/lib/libcrypto.dylib
):
cd s2geometry
mkdir build
cd build
cmake \
-DGTEST_ROOT=/path/to/googletest \
-DOPENSSL_ROOT_DIR=/usr/local/opt/[email protected] \
-S ..
# Build as normal
make -j8
If you get this warning:
CMake Warning at googletest/googletest/CMakeLists.txt:54 (project):
VERSION keyword not followed by a value or was followed by a value that
expanded to nothing.
I suspect there's an issue with using newer versions of GoogleTest (1.10.0):
-
Set
GTEST_ROOT
to the root of thegoogletest
repository, rather than thegoogletest
directory within the repository. -
In
s2geometry/CMakeLists.txt
, change:include_directories(${GTEST_ROOT}/include)
to:
include_directories(${GTEST_ROOT}/googletest/include)
There's some extra helpers in googletest/googletest/CMakeLists.txt
that set variables that other projects could use to find the googletest
include directory, which is probably the better way to fix this.
Unfortunately it looks like you need to be able to build tests successfully in order to run make install
, but that's another issue.
Edited (2021-02-28): Added -S
flag to cmake
call to make it explicitly specify it the source directory, rather than the build output directory, so that Makefile
always ends up in s2geometry/build/
, rather than s2geometry/
.