-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
On openSUSE Leap 15.6 with GCC 13 and Protobuf 25 the CMake configure step fails:
• The small Protobuf try-compile test links only -lprotobuf, but Protobuf 25 symbols require Abseil libraries, causing undefined reference errors (absl::lts_20240116::log_internal::MakeCheckOpString).
• GCC 13 is stricter with standard headers and exposes a missing #include in epee’s http code when using uint64_t.
These versions (GCC 13 and Protobuf 25) are standard on multiple modern distros (SUSE Leap, Fedora, Arch, etc), so this failure reproduces on common environments.
Repro
Build Monero 0.18.4.1 with GCC 13 + Protobuf 25.
• Protobuf try compile fails at link time with missing Abseil symbols.
• http_base.h fails to compile because uint64_t is not defined.
Root cause
• Protobuf 25 has hard dependencies on Abseil, but the CMake try-compile only links libprotobuf directly, not the full dependency set.
• GCC 13 enforces explicit inclusion of for fixed-width integer types.
Proposed changes
- Make CMake use the imported Protobuf target so transitive link dependencies are honored (requires CMake ≥ 3.5, already the minimum in build). Example:
find_package(Protobuf REQUIRED)
target_link_libraries(your_target PRIVATE protobuf::libprotobuf)
For try-compile checks, use the imported target or fall back to pkg-config --libs protobuf so Abseil is pulled in automatically.
- Set project-wide C++ standard to 17 in the top-level CMakeLists.txt to match Protobuf and Abseil headers. Avoid per-target downgrades to C++11/14.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
- Add the missing include in epee http base header:
// contrib/epee/include/net/http_base.h
#include <list>
#include <cstdint> // required for uint64_t
Impact
• With these changes Monero builds cleanly on GCC 13 + Protobuf 25 out of the box.
• Changes are toolchain-agnostic and do not affect runtime behavior.
• Reduces the need for downstream distro patches.
Notes
If upstream prefers to keep try-compile checks minimal, using pkg-config --libs protobuf for Protobuf ≥ 25 is a fallback option, but the cleaner solution is to rely on the CMake imported target (protobuf::libprotobuf).
Attached is my spec for openSUSE Leap, built with the command (rename the file from monero.spec.txt to monero.spec):
rpmbuild -ba /usr/src/packages/SPECS/monero.spec
complete prep + build:
%prep
%autosetup -n %{name}-%{version}
# Removido o tratamento de submódulos, pois o tarball não suporta Git diretamente
# Configurações do systemd e arquivos de configuração
sed -i '37i #include <cstdint>' contrib/epee/include/net/http_base.h
sed -i 's#^Description=Monero Full Node$#Description=%{display_name} Daemon#g' utils/systemd/%{daemon_name}.service
sed -i 's#^PIDFile=/run/monero/monerod.pid$#PIDFile=%{_rundir}/%{name}/%{daemon_name}.pid#g' utils/systemd/%{daemon_name}.service
sed -i 's#^ExecStart=%{_bindir}/monerod --config-file %{_sysconfdir}/%{daemon_name}.conf \\$#ExecStart=%{_bindir}/%{daemon_name} --detach --pidfile %{_rundir}/%{name}/%{daemon_name}.pid --config-file=%{_sysconfdir}/%{name}.conf --data-dir=%{_localstatedir}/lib/%{name}#g' utils/systemd/%{daemon_name}.service
sed -i 's#^ --detach --pidfile /run/monero/monerod.pid#ExecReload=/bin/kill -HUP \$MAINPID#g' utils/systemd/%{daemon_name}.service
sed -i 's#^User=monero$#User=%{name}#g' utils/systemd/%{daemon_name}.service
sed -i 's#^Group=monero$#Group=%{name}#g' utils/systemd/%{daemon_name}.service
sed -i 's#monerod#%{daemon_name}#g' utils/conf/%{daemon_name}.conf
sed -i 's#^data-dir=%{_localstatedir}/lib/monero$#data-dir=%{_localstatedir}/lib/%{name}#g' utils/conf/%{daemon_name}.conf
sed -i 's#wlog-file=%{_localstatedir}/log/monero/monero.log$#log-file=%{_localstatedir}/log/%{name}/%{name}.log#g' utils/conf/%{daemon_name}.conf
echo "d %{_rundir}/%{name} 0770 root %{name}" > rundir.conf
%build
%define __builder ninja
export CC=gcc-13
export CXX=g++-13
%cmake \
-DARCH=default \
-DBUILD_TESTS=OFF \
-DBUILD_GUI_DEPS=ON \
-DBUILD_SHARED_LIBS=OFF \
-DUSE_DEVICE_TREZOR=ON \
-DProtobuf_USE_STATIC_LIBS=OFF \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=ON \
-DCMAKE_CXX_FLAGS="%{optflags} -DBOOST_ASIO_DISABLE_STD_STRING_VIEW -std=gnu++17" \
-DCMAKE_REQUIRED_FLAGS="-std=gnu++17" \
-DCMAKE_REQUIRED_LINK_OPTIONS="-Wl,--no-as-needed -Wl,--copy-dt-needed-entries" \
-DCMAKE_REQUIRED_LIBRARIES="$(pkg-config --libs protobuf)" \
-DCMAKE_TRY_COMPILE_PLATFORM_VARIABLES="CMAKE_CXX_STANDARD;CMAKE_CXX_STANDARD_REQUIRED;CMAKE_CXX_EXTENSIONS;CMAKE_REQUIRED_FLAGS;CMAKE_REQUIRED_LINK_OPTIONS;CMAKE_REQUIRED_LIBRARIES" \
-DCMAKE_EXE_LINKER_FLAGS="%{?build_ldflags} -Wl,--no-as-needed $(pkg-config --libs protobuf)" \
-DCMAKE_SHARED_LINKER_FLAGS="%{?build_ldflags} -Wl,--no-as-needed $(pkg-config --libs protobuf)" \
-Wno-dev \
-DCMAKE_POLICY_DEFAULT_CMP0148=NEW \
-DMANUAL_SUBMODULES=1 \
-DSTACK_TRACE=OFF
%cmake_build