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

mapnik fails to build with ubuntu/debian with scons: building terminated because of errors #4429

Open
flomickl opened this issue Jan 15, 2024 · 4 comments

Comments

@flomickl
Copy link

Hi all,

I am trying to build mapnik with ubuntu (LTS and 23.10). Also with debian 12.

All dependencies seem to be installed.
I have no clue what to do in this situation. Anyone an idea what is going on?

The error message is as follows

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
include/mapnik/filesystem.hpp:39:25: error: ‘error_code’ in namespace ‘std’ does not name a type
   39 | using error_code = std::error_code;
      |                         ^~~~~~~~~~
include/mapnik/filesystem.hpp:31:1: note: ‘std::error_code’ is defined in header ‘<system_error>; did you forget to ‘#include <system_error>’?
   30 | #include <filesystem>
  +++ |+#include <system_error>
   31 | #endif
src/fs.cpp: In function ‘bool mapnik::util::exists(const std::string&)’:
src/fs.cpp:40:12: error: ‘fs’ has not been declared
   40 |     return fs::exists(filepath);
      |            ^~
src/fs.cpp: In function ‘bool mapnik::util::is_directory(const std::string&)’:
src/fs.cpp:49:12: error: ‘fs’ has not been declared
   49 |     return fs::is_directory(filepath);
      |            ^~
src/fs.cpp: In function ‘bool mapnik::util::is_regular_file(const std::string&)’:
src/fs.cpp:58:12: error: ‘fs’ has not been declared
   58 |     return fs::is_regular_file(filepath);
      |            ^~
src/fs.cpp: In function ‘bool mapnik::util::remove(const std::string&)’:
src/fs.cpp:67:12: error: ‘fs’ has not been declared
   67 |     return fs::remove(filepath);
      |            ^~
src/fs.cpp: In function ‘bool mapnik::util::is_relative(const std::string&)’:
src/fs.cpp:76:5: error: ‘fs’ has not been declared
   76 |     fs::path child_path(filepath);
      |     ^~
src/fs.cpp:78:14: error: ‘child_path’ was not declared in this scope; did you mean ‘filepath’?
   78 |     return (!child_path.has_root_directory() && !child_path.has_root_name());
      |              ^~~~~~~~~~
      |              filepath
src/fs.cpp: In function ‘std::string mapnik::util::make_relative(const std::string&, const std::string&)’:
src/fs.cpp:86:5: error: ‘fs’ has not been declared
   86 |     fs::path absolute_path(base);
      |     ^~
src/fs.cpp:89:9: error: ‘fs’ has not been declared
   89 |     if (fs::is_symlink(absolute_path))
      |         ^~
src/fs.cpp:89:24: error: ‘absolute_path’ was not declared in this scope
   89 |     if (fs::is_symlink(absolute_path))
      |                        ^~~~~~~~~~~~~
src/fs.cpp:91:25: error: ‘fs’ has not been declared
   91 |         absolute_path = fs::read_symlink(absolute_path);
      |                         ^~
src/fs.cpp:93:12: error: ‘fs’ has not been declared
   93 |     return fs::absolute(absolute_path.parent_path() / filepath).string();
      |            ^~
src/fs.cpp:93:25: error: ‘absolute_path’ was not declared in this scope
   93 |     return fs::absolute(absolute_path.parent_path() / filepath).string();
      |                         ^~~~~~~~~~~~~
src/fs.cpp: In function ‘std::string mapnik::util::make_absolute(const std::string&, const std::string&)’:
src/fs.cpp:99:12: error: ‘fs’ has not been declared
   99 |     return fs::absolute(fs::path(base) / filepath).string();
      |            ^~
src/fs.cpp:99:25: error: ‘fs’ has not been declared
   99 |     return fs::absolute(fs::path(base) / filepath).string();
      |                         ^~
src/fs.cpp: In function ‘std::string mapnik::util::dirname(const std::string&)’:
src/fs.cpp:104:5: error: ‘fs’ has not been declared
  104 |     fs::path bp(filepath);
      |     ^~
src/fs.cpp:105:12: error: ‘bp’ was not declared in this scope
  105 |     return bp.parent_path().string();
      |            ^~
src/fs.cpp: In function ‘std::string mapnik::util::basename(const std::string&)’:
src/fs.cpp:110:5: error: ‘fs’ has not been declared
  110 |     fs::path bp(value);
      |     ^~
src/fs.cpp:111:12: error: ‘bp’ was not declared in this scope
  111 |     return bp.filename().string();
      |            ^~
src/fs.cpp: In function ‘std::vector<std::__cxx11::basic_string<char> > mapnik::util::list_directory(const std::string&)’:
src/fs.cpp:117:5: error: ‘fs’ has not been declared
  117 |     fs::directory_iterator end_itr;
      |     ^~
src/fs.cpp:125:10: error: ‘fs’ has not been declared
  125 |     for (fs::directory_iterator itr(dir); itr != end_itr; ++itr)
      |          ^~
src/fs.cpp:125:43: error: ‘itr’ was not declared in this scope
  125 |     for (fs::directory_iterator itr(dir); itr != end_itr; ++itr)
      |                                           ^~~
src/fs.cpp:125:50: error: ‘end_itr’ was not declared in this scope
  125 |     for (fs::directory_iterator itr(dir); itr != end_itr; ++itr)
      |                                                  ^~~~~~~
scons: *** [src/fs.os] Error 1
In file included from include/mapnik/well_known_srs.hpp:27,
                 from src/well_known_srs.cpp:24:
include/mapnik/enumeration.hpp:213:7: warning: type attributes ignored after type is already defined [-Wattributes]
  213 |       enumeration<enum_class, type_alias##_to_string, type_alias##_from_string, type_alias##_lookup>;
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/well_known_srs.cpp:79:1: note: in expansion of macro ‘IMPLEMENT_ENUM’
   79 | IMPLEMENT_ENUM(well_known_srs_e, well_known_srs_enum)
      | ^~~~~~~~~~~~~~
In file included from include/mapnik/map.hpp:35,
                 from demo/c++/rundemo.cpp:24:
include/mapnik/font_engine_freetype.hpp:135:35: warning: type attributes ignored after type is already defined [-Wattributes]
  135 | extern template class MAPNIK_DECL singleton<freetype_engine, CreateUsingNew>;
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from demo/c++/rundemo.cpp:32:
include/mapnik/datasource_cache.hpp:69:35: warning: type attributes ignored after type is already defined [-Wattributes]
   69 | extern template class MAPNIK_DECL singleton<datasource_cache, CreateStatic>;
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scons: building terminated because of errors.
make: *** [Makefile:48: mapnik] Error 2

My Containerfile to reproduce this error is:

FROM ubuntu:23.10

ENV BUILD_DEPENDENCIES="build-essential \
    ca-certificates \
    git \
    icu-devtools \
    libboost-dev \
    libboost-filesystem-dev \
    libboost-program-options-dev \
    libboost-regex-dev \
    libboost-thread-dev \
    libboost-system-dev \
    libcairo-dev \
    libfreetype6-dev \
    libgdal-dev \
    libharfbuzz-dev \
    libicu-dev \
    libjpeg-dev \
    libpq-dev  \
    libproj-dev \
    librasterlite2-dev \
    libsqlite3-dev \
    libtiff-dev \
    libwebp-dev \
    scons \
    python3"

RUN apt update && apt upgrade -y && apt install -y $BUILD_DEPENDENCIES

# test scons and python version
RUN scons -v && \
    echo "====================" && \
    python3 --version

RUN git clone https://github.com/mapnik/mapnik.git && \
    cd mapnik && \
    git submodule update --init && \
    PYTHON=python3 ./configure PREFIX=/opt/mapnik && \
    python3 /usr/bin/scons configure && \
    JOBS=4 make PYTHON=python3

image can be build via docker/podman
docker build -t mapnik:latest .

Here is the complete output from the Last RUN section
output.md

@Jomy10
Copy link

Jomy10 commented Jan 24, 2024

I'm having the same error. I read that it could be something to do with c++17, as I can see in the build commands, the flag -std=c++14 is passed to the C compiler. I think changing to c++17 might fix this?

My Dockerfile is this:

FROM debian

RUN apt-get update
RUN apt-get install -y \
        ca-certificates \
        gnupg \
        lsb-release \
        curl \
        git \
        curl \
        libcurl4 \
        libcurl4-gnutls-dev \
        patch \
        clang \
        make \
        zlib1g \
        zlib1g-dev \
        libffi-dev \
        openssl \
        bzip2 \
        readline-common \
        libreadline8 \
        sqlite3 \
        libsqlite3-dev \
        bash \
        libicu-dev \
        libfreetype-dev \
        libharfbuzz-dev \
        postgresql-15 \
        postgresql-server-dev-15 \
        postgresql-client-15 \
        libpq5 \
        libpq-dev \
        cmake \
        make \
        libtiff-dev \
        libcli11-dev \
        libexpat1-dev \
        npm \
        python3-dev \
        ruby

ENV CC clang
ENV CXX clang++

# Boost
RUN curl -L https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz -o boost.tar.xz
RUN tar -xvf boost.tar.xz
RUN cd boost-1.84.0 && ./bootstrap.sh --prefix=/usr --with-python=python3 --with-toolset=clang
RUN cd boost-1.84.0 && ./b2 install -j$(nproc) threading=multi link=shared toolset=clang

# Postgis
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN echo "Package: *\nPin: release o=apt.postgresql.org\nPin-Priority: 500"  >> /etc/apt/preferences.d/pgdg.pref
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y postgresql-15-postgis-3

# Python
ENV PYENV_ROOT /root/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN curl curl https://pyenv.run | bash
RUN pyenv update
RUN pyenv install 3.10
RUN pyenv global 3.10
RUN pyenv rehash
RUN python --version

# Libproj
RUN curl -L https://download.osgeo.org/proj/proj-9.3.1.tar.gz -o proj.tar.gz
RUN tar -xvf proj.tar.gz
RUN cd proj-* && mkdir build && cd build && CC=clang CXX=clang++ cmake -DBUILD_TESTING=OFF .. && cmake --build . && cmake --build . --target install

# Mapnik
RUN git clone https://github.com/mapnik/mapnik.git
RUN cd mapnik && git submodule update --init
RUN cd mapnik && echo "PROJ_INCLUDES = '/usr/local/include:/usr/local/include/proj'" >> config.py && echo "PROJ_LIBS = '/usr/local/lib'" >> config.py && echo "PROJ='yes'" >> config.py
RUN cd mapnik && ruby -e "f = File.read('SConstruct'); i = f.index(\"    if env['PROJ']:\"); es = \"    else:\n        env['SKIPPED_DEPS'].append('proj')\"; e = f.index(es); File.write('SConstruct', f[..i-1] + f[e+1+es.length..])"
RUN cd mapnik && ./configure -Q VERBOSE=1 CC=clang CXX=clang++ && make && make install

@Jomy10
Copy link

Jomy10 commented Jan 24, 2024

adding CXX_STD=17 might resolve the issue.

@hummeltech
Copy link
Contributor

hummeltech commented Jan 29, 2024

If you are going to use a clone of https://github.com/mapnik/mapnik.git, I might suggest using CMake to build Mapnik. As far as I understand, it will be the recommended method (and potentially the only supported one) to build the upcoming 4.x.x releases.

@mkesper
Copy link

mkesper commented Apr 9, 2024

May I suggest updating the build instructions for modern systems. They are very out of date.

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

4 participants