Abseil linking issues while building from scratch
What version of protobuf and what language are you using? Version: main Language: C++
What operating system (Linux, Windows, ...) and version? MacOS Sonoma 14.3.1 What runtime / compiler are you using (e.g., python version or gcc version) cmake 3.30.0 + Apple clang 15.0.0 (clang-1500.1.0.2.5) What did you do?
git clone https://github.com/protocolbuffers/protobuf
cd protobuf
mkdir build
cd build
cmake ..
What did you expect to see A proper build setup, so I could launch
make install
What did you see instead?
-- The C compiler identification is AppleClang 15.0.0.15000100
-- The CXX compiler identification is AppleClang 15.0.0.15000100
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
--
-- 29.0.0
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT - Failed
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/lib/libz.tbd (found version "1.2.12")
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS - Success
CMake Warning at third_party/abseil-cpp/CMakeLists.txt:82 (message):
A future Abseil release will default ABSL_PROPAGATE_CXX_STD to ON for CMake
3.8 and up. We recommend enabling this option to ensure your project still
builds correctly.
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17 - Failed
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20 - Failed
-- Configuring done (1.1s)
CMake Error at third_party/abseil-cpp/CMake/AbseilHelpers.cmake:317 (target_link_libraries):
The link interface of target "random_mocking_bit_gen" contains:
absl::random_internal_mock_overload_set
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
third_party/abseil-cpp/absl/random/CMakeLists.txt:100 (absl_cc_library)
-- Generating done (0.6s)
CMake Generate step failed. Build files cannot be regenerated correctly.
Anything else we should know about your project / environment Before attempting doing anything I have intentionally removed protobuf and abseil previously installed by brew:
% brew uninstall protobuf
Uninstalling /opt/homebrew/Cellar/protobuf/27.1... (430 files, 14.6MB)
==> Autoremoving 1 unneeded formula:
abseil
Uninstalling /opt/homebrew/Cellar/abseil/20240116.2... (748 files, 10.9MB)
I have discovered that setting ABSL_BUILD_TESTING to ON fixes the problem with this step, but it still looks like an issue to be fixed. But when I call
cmake .. -DABSL_BUILD_TESTING=ON -DCMAKE_CXX_STANDARD=17 && make install
I get this output:
error: static assertion failed due to requirement '!absl::is_trivially_relocatable<S>::value':
static_assert(!absl::is_trivially_relocatable<S>::value, "");
I turned the ABSL_BUILD_TESTING to ON and it goes smoothly without any errors. Maybe this issue is fixed.
@sevaserg - is this still an issue for you on the latest release? It seems like @HisuianZoroark69 is reporting that it is working for them.
It is also not clear to me that this is an issue with Protobuf vs Abseil.
@sevaserg - is this still an issue for you on the latest release? It seems like @HisuianZoroark69 is reporting that it is working for them.
I still have issues with it. I try to use protobuf without manual addition of abseil things and this is what I get:
[build] Undefined symbols for architecture arm64:
[build] "void absl::lts_20240722::log_internal::LogMessage::CopyToEncodedBuffer<(absl::lts_20240722::log_internal::LogMessage::StringType)0>(std::__1::basic_string_view<char, std::__1::char_traits<char>>)", referenced from:
and I get this for all absl::lts_20240722::log_internal things.
It is also not clear to me that this is an issue with Protobuf vs Abseil.
Assuming that Protobuf is built upon Abseil, it looks like it is a Protobuf's abseil inclusion problem. I have tried the build with result above using the newest available brew packages now (I guess this is the most correct way to use protobuf on mac), these are their versions.
brew info abseil
==> abseil: stable 20240722.0 (bottled), HEAD
brew info protobuf
==> protobuf: stable 28.2 (bottled)
The way I get my project to include protobuf (so it builds and works) is:
...
set (CMAKE_CXX_STANDARD 17)
...
find_package(Protobuf)
if (NOT Protobuf_FOUND)
add_subdirectory(${PROJECT_SOURCE_DIR}/path/to/protobuf ${PROJECT_BINARY_DIR}/protobuf)
else()
if (Protobuf_VERSION VERSION_GREATER_EQUAL 3.27.0)
find_package(absl REQUIRED)
endif()
endif()
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${absl_INCLUDE_DIRS})
if (Protobuf_VERSION VERSION_GREATER_EQUAL 3.27.0)
target_link_libraries(projectname PUBLIC ... ${Protobuf_LIBRARIES} absl::log_internal_check_op absl::log_internal_message absl::raw_logging_internal absl::spinlock_wait)
else()
target_link_libraries(projectname PUBLIC ... ${Protobuf_LIBRARIES})
endif()
I would like not to link the absl deps by myself.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.