mapnik / mapnik

Mapnik is an open source toolkit for developing mapping applications

Home Page:http://mapnik.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mapnik installation on Windows giving C++14 standard issue with clang or g++

shanti-tripathy-impledge opened this issue · comments

I followed the steps mentioed in https://mapnik.org/pages/downloads.html to install mapnik from source.

I have clang version 14. I also have g++ version 6.3.0. But when I am trying to install mapnik on Windows, it says "C++ compiler does not support C++14 standard (-std=c++14), which is required. Please upgrade your compiler"

$ ./configure CXX=clang++-14 CC=clang-14
scons: Reading SConscript files ...

Welcome to Mapnik...

Configuring build environment...
Configuring on Windows in release mode...
Checking for pkg-config... no
Checking for freetype-config... no
Checking for dlfcn.h support ... no
Checking if compiler (clang++-14) supports -std=c++14 flag... (cached) no
C++ compiler does not support C++14 standard (-std=c++14), which is required. Please upgrade your compiler

The config.log contents are:

file D:\projects\qgis\mapnik\SConstruct,line 1266:
Configure(confdir = .sconf_temp)
scons: Configure: Checking for pkg-config...
pkg-config --atleast-pkgconfig-version=0.15.0
'pkg-config' is not recognized as an internal or external command,
operable program or batch file.
scons: Configure: no

scons: Configure: Checking for freetype-config...
freetype-config --libs --cflags
'freetype-config' is not recognized as an internal or external command,
operable program or batch file.
scons: Configure: no

scons: Configure: Checking for dlfcn.h support ...
.sconf_temp\conftest_2.cpp <-
|
|
|#include <dlfcn.h>
|
|int main()
|{
| return 0;
|}
|
|
clang++-14 /Fo.sconf_temp\conftest_2.obj /c .sconf_temp\conftest_2.cpp /TP -std=c++14 -DU_USING_ICU_NAMESPACE=0 /nologo /D-DMAPNIK_MEMORY_MAPPED_FILE /Iinclude /ID:\usr\include
'clang++-14' is not recognized as an internal or external command,
operable program or batch file.
scons: Configure: no

.sconf_temp\conftest_3.cpp <-
|
|
|int main()
|{
|#if __cplusplus >= 201402L
| return 0;
|#else
| return -1;
|#endif
|}
|
|
clang++-14 /Fo.sconf_temp\conftest_3.obj /c .sconf_temp\conftest_3.cpp /TP -std=c++14 -DU_USING_ICU_NAMESPACE=0 /nologo /D-DMAPNIK_MEMORY_MAPPED_FILE /Iinclude /ID:\usr\include
'clang++-14' is not recognized as an internal or external command,
operable program or batch file.
scons: Configure: Checking if compiler (clang++-14) supports -std=c++14 flag...
scons: Configure: (cached) no


If you see config.log, it says "'clang++-14' is not recognized as an internal or external command,"

Why is it trying to run the command with the version name? If this is not the way, how then should I pass the version to ./configure command?

I tried with g++ as well and got similar issues. My previous clang was version 12 that comes with Visual Studio. When I run just ./configure, the config log says:

file D:\projects\qgis\mapnik\SConstruct,line 1266:
Configure(confdir = .sconf_temp)
scons: Configure: Checking for pkg-config...
pkg-config --atleast-pkgconfig-version=0.15.0
'pkg-config' is not recognized as an internal or external command,
operable program or batch file.
scons: Configure: no

scons: Configure: Checking for freetype-config...
freetype-config --libs --cflags
'freetype-config' is not recognized as an internal or external command,
operable program or batch file.
scons: Configure: no

scons: Configure: Checking for dlfcn.h support ...
.sconf_temp\conftest_2.cpp <-
|
|
|#include <dlfcn.h>
|
|int main()
|{
| return 0;
|}
|
|
c++ /Fo.sconf_temp\conftest_2.obj /c .sconf_temp\conftest_2.cpp /TP -std=c++14 -DU_USING_ICU_NAMESPACE=0 /nologo /D-DMAPNIK_MEMORY_MAPPED_FILE /Iinclude /ID:\usr\include
c++: error: /Fo.sconf_temp\conftest_2.obj: No such file or directory
c++: error: /c: No such file or directory
c++: error: /TP: No such file or directory
c++: error: /nologo: No such file or directory
c++: error: /D-DMAPNIK_MEMORY_MAPPED_FILE: No such file or directory
c++: error: /Iinclude: No such file or directory
c++: error: /ID:\usr\include: Invalid argument
scons: Configure: no

.sconf_temp\conftest_3.cpp <-
|
|
|int main()
|{
|#if __cplusplus >= 201402L
| return 0;
|#else
| return -1;
|#endif
|}
|
|
c++ /Fo.sconf_temp\conftest_3.obj /c .sconf_temp\conftest_3.cpp /TP -std=c++14 -DU_USING_ICU_NAMESPACE=0 /nologo /D-DMAPNIK_MEMORY_MAPPED_FILE /Iinclude /ID:\usr\include
c++: error: /Fo.sconf_temp\conftest_3.obj: No such file or directory
c++: error: /c: No such file or directory
c++: error: /TP: No such file or directory
c++: error: /nologo: No such file or directory
c++: error: /D-DMAPNIK_MEMORY_MAPPED_FILE: No such file or directory
c++: error: /Iinclude: No such file or directory
c++: error: /ID:\usr\include: Invalid argument
scons: Configure: Checking if compiler (c++) supports -std=c++14 flag...
scons: Configure: (cached) no


When clang v12 didn't work, I installed LLVM + clang v14. I also tried by exporting variables first like export CXX="clang++-14" and export CC="clang-14". But no luck...
Please help as I am badly stuck in this for the past 2 days...
Thanks

Hi, so if you are building the master branch of mapnik, I think you won't succeed in building with scons on windows.

I recommend cmake on windows. You can take a look into the ci workflows or in the docs folder for the cmake build instructions.

Feel free to ask any further questions :)

Hi,
Well, I started trying with vcpkg. I was able to install mapnik and other supporting libraries like boost etc.. But the sample C++ code present in mapnik needs some more libraries like Qt etc...
When I tried
c:\src\vcpkg>vcpkg install qt5
It failed with:
error: building qt5-base:x64-windows failed with: BUILD_FAILED

Building qt5-base[core]:x64-windows...
-- Figuring out qt target mkspec. Target arch x64
-- Target mkspec set to: win32-msvc
-- Host mkspec not set. Qt's own buildsystem will try to figure out the host system
-- Using cached qtbase-everywhere-opensource-src-5.15.4.tar.xz.
-- Cleaning sources at C:/src/vcpkg/buildtrees/qt5-base/src/5.15.4-2d510dee77.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source C:/src/vcpkg/downloads/qtbase-everywhere-opensource-src-5.15.4.tar.xz
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:128 (message):
Command failed: "C:/Program Files/CMake/bin/cmake.exe" -E tar xjf C:/src/vcpkg/downloads/qtbase-everywhere-opensource-src-5.15.4.tar.xz
Working Directory: C:/src/vcpkg/buildtrees/qt5-base/src/5.15.4-2d510dee77.clean.tmp
Error code: 1
See logs for more information:
C:\src\vcpkg\buildtrees\qt5-base\extract-err.log

Call Stack (most recent call first):
scripts/cmake/vcpkg_extract_source_archive.cmake:210 (vcpkg_execute_required_process)
scripts/cmake/vcpkg_extract_source_archive_ex.cmake:32 (vcpkg_extract_source_archive)
ports/qt5-base/cmake/qt_download_submodule.cmake:32 (vcpkg_extract_source_archive_ex)
ports/qt5-base/portfile.cmake:57 (qt_download_submodule)
scripts/ports.cmake:146 (include)

Can you suggest a way out here?

Also is installing mapnik with vcpkg same as installing mapnik with cmake, in terms of the end result? Will I get binaries that can be used in C++ code if I install using Cmake?

Or will Cmake give a desktop application for mapnik?

If you don't need the viewer application, you can disable the build and drop qt. It would save you a lot of compile time. -DBUILD_DEMO_VIEWER=OFF when you are configuring the project

Or you download the prebuild qt binaries and create an empty overlay port for qt in vcpkg. If you want to build it yourself, you would need to send me the linked error log file.

I finally managed to download the qt binaries as well using vcpkg install qt5. The issue was that there was insufficient space in my disk. So I moved it to D:/ where there was space and this time it was able to download.

However, I am not sure of the next steps. Like, I know I need to import/include these binaries in my C++ code. But when I look for sample code for C++ in Mapnik, I get pre-requisites like Mapnik-config path should be set in environment variables etc. How do I do it in my case (as these are steps for those who have run ./configure not vcpkg install)? Where do I get Mapnik-config from?

It depends on what you want to accomplish.
If you have a C++ project and want to consume mapnik. You would need to install mapnik with the cmake install target.
Then you can just use CMake`s find package calls to resolve mapnik. See https://github.com/mapnik/mapnik/blob/master/docs/cmake-usage.md#usage

If you want to build mapnik-python or node-mapnik, it is currently not really possible on windows. Only if you take the WIP branches of me.

You can take a look at my integration test project on how to use mapnik in your own c++ project https://github.com/mathisloge/mapnik-vcpkg-test

Ok, I will try to implement cmake project using your project as sample... will ask you if I am stuck anywhere. I am pretty new to cmake environment.
Thanks for your help...

will close as resolved