Fails to build with GCC 14
sebastic opened this issue · 1 comments
As reported in Debian Bug #1075352, osmium-tool fails to build with GCC 14.
It's actually the embedded copy of rapidjson 1.1.0 that's the issue:
In file included from /<<PKGBUILDDIR>>/src/command_export.hpp:34,
from /<<PKGBUILDDIR>>/src/commands.cpp:12:
/<<PKGBUILDDIR>>/include/rapidjson/document.h: In member function ‘rapidjson::GenericStringRef<CharType>& rapidjson::GenericStringRef<CharType>::operator=(const rapidjson::GenericStringRef<CharType>&)’:
/<<PKGBUILDDIR>>/include/rapidjson/document.h:319:82: error: assignment of read-only member ‘rapidjson::GenericStringRef<CharType>::length’
319 | GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }
| ~~~~~~~^~~~~~~~~~~~
This is fixed upstream with Tencent/rapidjson#719 but there hasn't been a release since 2016, the embedded copy likely needs to be updated to a recent git snapshot.
I ran into the same problem. I'm on a Gentoo Linux server and have Gentoo's package installed:
jlpoole@ryzdesk /usr/local/src/osmium-tool/build $ date; eix -I rapidjson
Sun Sep 1 11:35:28 AM PDT 2024
[I] dev-libs/rapidjson
Available versions: 1.1.0-r4^t **9999*l^t {doc examples test}
Installed versions: 1.1.0-r4^t(01:35:23 PM 06/01/2024)(-doc -examples -test)
Homepage: https://rapidjson.org/
Description: A fast JSON parser/generator for C++ with both SAX/DOM style API
jlpoole@ryzdesk /usr/local/src/osmium-tool/build $
So, to skip the included rapidjson and utilize Gentoo's which has been successfully built, I performed the following modifications:
jlpoole@ryzdesk /usr/local/src/osmium-tool/build $ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: ../CMakeLists.txt
modified: ../test/CMakeLists.txt
no changes added to commit (use "git add" and/or "git commit -a")
jlpoole@ryzdesk /usr/local/src/osmium-tool/build $ git --no-pager diff ../CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 45a1d04..23d2044 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -209,8 +209,12 @@ configure_file(
${PROJECT_SOURCE_DIR}/osmium-wrapper.in
${PROJECT_BINARY_DIR}/osmium
)
-
-include_directories(SYSTEM include)
+#
+# 9/1/24 jlpoole: removing "include" since rapidjosn breaks the build
+# and I already have rapidjson installed through Gentoo's portage
+#
+#include_directories(SYSTEM include)
+find_package(RapidJSON REQUIRED)
include_directories(${PROJECT_BINARY_DIR}/src)
#-----------------------------------------------------------------------------
jlpoole@ryzdesk /usr/local/src/osmium-tool/build $ git --no-pager diff ../test/CMakeLists.txt
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f3eb779..d25c519 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -9,7 +9,11 @@
include_directories(include)
include_directories(../src)
include_directories(../src/extract)
-include_directories(../include)
+#
+# 9/1/24 jlpoole: rem'ing like I did for projects CMakeLists.txt, see ../CMakeLists.txt
+#
+#include_directories(../include)
+find_package(RapidJSON REQUIRED)
set(ALL_UNIT_TESTS
cat/test_setup.cpp
jlpoole@ryzdesk /usr/local/src/osmium-tool/build $
Thereafter, I successfully built the project and successfully ran the basic tests:
51/351 Test #351: unknown_command .................................. Passed 0.00 sec
100% tests passed, 0 tests failed out of 351
Total Test time (real) = 10.63 sec
jlpoole@ryzdesk /usr/local/src/osmium-tool/build $
Note: I did have to perform some modifications on the dependency project protozero, see: Build fails at Linking CXX executable writer_tests and while the build did not successfully complete, e.g. the linking failed, the object files needed by the intermediate dependency project, libosmium, were sufficient to allow libosmium to successfully build.
In conclusion, to get this project to build on Gentoo Linux 9/1/2024, I had to modify two files in this project, and make a modification to accomplish a partial build in protozero.