Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error(s): Use C++17 instead of C++14 for compilation #4405

Closed
luk-brue opened this issue Sep 15, 2023 · 2 comments
Closed

Build error(s): Use C++17 instead of C++14 for compilation #4405

luk-brue opened this issue Sep 15, 2023 · 2 comments

Comments

@luk-brue
Copy link

luk-brue commented Sep 15, 2023

Also see my SO Post.

When I want to build current master from source on my Linux Mint 21.2 machine, there is an error coming up.

This is what I tried:

So, ./configure says I have all dependencies. So i go ahead and make.

First part of the build goes well, although there were 26 warnings mostly about unary functions being deprecated.

Then we come to the output below:

Somehow, scons is rerunning configuration for some reasons I don't know. Well ok.

Then you see clang++ being called with the -std=c++14 flag.

Then you see the error at the end of the output: std::filesystem is not recognized as a namespace name.

What could be the cause of this?
Someone on SO suggested that the filesystem library is implemented only since c++17.

scons: done building targets.
# then install the rest with -j1
scons/scons.py -j1 --config=cache --implicit-cache --max-drift=1
scons: Reading SConscript files ...
Using previous successful configuration...
Re-configure by running "python scons/scons.py configure".

Welcome to Mapnik...

scons: done reading SConscript files.
scons: Building targets ...
clang++ -o benchmark/src/normalize_angle.o -c -std=c++14 -DU_USING_ICU_NAMESPACE=0 -D_GLIBCXX_USE_CXX11_ABI=0 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -pthread -ftemplate-depth-300 -Wsign-compare -Wno-unsequenced -Wtautological-compare -Wheader-hygiene -O3 -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=70201 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=70201 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -DSVG_RENDERER -DHAVE_CAIRO -Ibenchmark/include -Imason_packages/.link/include/cairo -Imason_packages/.link/include/pixman-1 -Ideps -Ideps/mapbox/polylabel/include -Ideps/mapbox/protozero/include -Ideps/mapbox/geometry/include -Ideps/mapbox/variant/include -Ideps/agg/include -Iinclude -Imason_packages/.link/include -Imason_packages/.link/include/freetype2 -Imason_packages/.link/include/libpng16 -Imason_packages/linux-x86_64/libgdal/2.2.3/include benchmark/src/normalize_angle.cpp
clang++ -o src/mapnik.os -c -std=c++14 -DU_USING_ICU_NAMESPACE=0 -D_GLIBCXX_USE_CXX11_ABI=0 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -pthread -ftemplate-depth-300 -Wsign-compare -Wno-unsequenced -Wtautological-compare -Wheader-hygiene -O3 -fPIC -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=70201 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -DSVG_RENDERER -Ideps -Ideps/mapbox/polylabel/include -Ideps/mapbox/protozero/include -Ideps/mapbox/geometry/include -Ideps/mapbox/variant/include -Ideps/agg/include -Iinclude -Imason_packages/.link/include -Imason_packages/.link/include/freetype2 -Imason_packages/.link/include/libpng16 -Imason_packages/linux-x86_64/libgdal/2.2.3/include -Imason_packages/.link/include/cairo -Imason_packages/.link/include/pixman-1 src/mapnik.cpp
clang++ -o src/fs.os -c -std=c++14 -DU_USING_ICU_NAMESPACE=0 -D_GLIBCXX_USE_CXX11_ABI=0 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -pthread -ftemplate-depth-300 -Wsign-compare -Wno-unsequenced -Wtautological-compare -Wheader-hygiene -O3 -fPIC -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=70201 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -DSVG_RENDERER -Ideps -Ideps/mapbox/polylabel/include -Ideps/mapbox/protozero/include -Ideps/mapbox/geometry/include -Ideps/mapbox/variant/include -Ideps/agg/include -Iinclude -Imason_packages/.link/include -Imason_packages/.link/include/freetype2 -Imason_packages/.link/include/libpng16 -Imason_packages/linux-x86_64/libgdal/2.2.3/include -Imason_packages/.link/include/cairo -Imason_packages/.link/include/pixman-1 src/fs.cpp
In file included from src/fs.cpp:26:
include/mapnik/filesystem.hpp:38:21: error: expected namespace name
namespace fs = std::filesystem;
               ~~~~~^
include/mapnik/filesystem.hpp:39:25: error: no type named 'error_code' in namespace 'std'
using error_code = std::error_code;
                   ~~~~~^
src/fs.cpp:40:12: error: use of undeclared identifier 'fs'
    return fs::exists(filepath);
           ^

Here is what I tried

First of all, I tried to simulate what Re-configure by running "python scons/scons.py configure". has done by running that command manually. As I said, when I used ./configure prior to building, all dependencies were found or paths were found and automatically added (conveniently). But when running python scons/scons.py configure manually, it suddenly says that the path to ICU_DATA can not be found. Well, maybe this is due to a difference between calling ./configure and calling the local scons.py. Or due to somethings that were changed during the first part of the build.

I tried configuring it to run with the c++17 standard, but at this point I failed, probably because I wrote CXX_STD = '17' into the config.py file. Maybe i should prefix it with the c++.

Please help me:

Is the error actually being caused by using too old c++ standard for the code? Or is it something else?

Thanks!

Update 1

Somehow i missed a lot of dependencies, which previously went unreconized by ./configure, but when i ran it again, it pointed out al lot of missing packages. Convieniently, they are all listed on the Ubuntu Install Wiki. For some packages there were no installation candidates but suggested replacements, so installed those replacements.

Anyway, this does not fix the problem, the error persists, the only thing that is different is that it is now using the default compiler c++ instead of clang++ and therefore error message varies a little bit.

c++ -o src/mapnik.os -c -std=c++14 -DU_USING_ICU_NAMESPACE=0 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -pthread -ftemplate-depth-300 -Wsign-compare -O3 -fPIC -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=80201 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -Ideps -Ideps/mapbox/polylabel/include -Ideps/mapbox/protozero/include -Ideps/mapbox/geometry/include -Ideps/mapbox/variant/include -Ideps/agg/include -Iinclude -I/usr/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/postgresql -I/usr/include/gdal -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid src/mapnik.cpp
c++ -o src/fs.os -c -std=c++14 -DU_USING_ICU_NAMESPACE=0 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -pthread -ftemplate-depth-300 -Wsign-compare -O3 -fPIC -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=80201 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -Ideps -Ideps/mapbox/polylabel/include -Ideps/mapbox/protozero/include -Ideps/mapbox/geometry/include -Ideps/mapbox/variant/include -Ideps/agg/include -Iinclude -I/usr/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/postgresql -I/usr/include/gdal -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid src/fs.cpp
In file included from src/fs.cpp:26:
include/mapnik/filesystem.hpp:38:21: error: ‘filesystem’ is not a namespace-name; did you mean ‘system’?
   38 | namespace fs = std::filesystem;
      |                     ^~~~~~~~~~
      |                     system

Update 2

I found the way to pass the std=c++17 flag: Running

./configure CXX_STD="17"

seems to work! The compiler operates with the -std=c++17 flag. The error does not reappear! Yay.

So we are making it through compilation, but next problems show up.

c++ -o demo/c++/rundemo demo/c++/rundemo.o -Ldeps/agg -Lsrc -Lsrc/json -Lsrc/wkt -Lfreetype -L/usr/lib -L/usr/lib/x86_64-linux-gnu -lmapnik -lagg -lboost_regex -lcairo -lpng -lproj -lsqlite3 -ltiff -lwebp -licui18n -lharfbuzz -ljpeg -licuuc -lfreetype -lz -ldl -lsqlite3 -lpthread
/usr/bin/ld: demo/c++/rundemo.o: in function `main':
rundemo.cpp:(.text.startup+0x26a2): undefined reference to `mapnik::feature_style_processor<mapnik::agg_renderer<mapnik::image<mapnik::rgba8_t>, mapnik::label_collision_detector4> >::apply(double)'
/usr/bin/ld: rundemo.cpp:(.text.startup+0x2ac3): undefined reference to `mapnik::feature_style_processor<mapnik::cairo_renderer<std::shared_ptr<_cairo> > >::apply(double)'
collect2: error: ld returned 1 exit status
scons: *** [demo/c++/rundemo] Error 1
scons: building terminated because of errors.
make: *** [Makefile:48: mapnik] Fehler 2

At this point, I might give up.

Update 3

Wait no, there is hope: Issue #4243 could be the solution, even though open since 2021. This involves changing out 3 files, e.g. patching some holes. With the Fixes in that Issue it managed to build completely! But let's test it.

Unfortunately, the next misery awaits:

upon make test, many tests fail

@luk-brue luk-brue changed the title Build error Build error(s): Use C++17 instead of C++14 for compilation Sep 16, 2023
@luk-brue
Copy link
Author

all of this also might be related to issue #4310 still being open

@mathisloge
Copy link
Collaborator

For c++14 you had to use boost filesystem instead of std::
However, since now the min. c++ version changed to c++17, I'll close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants