0

I installed mapnik 4.0.0. Then I tried to compile an example:

#include <mapnik/map.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/image.hpp>
#include <mapnik/image_util.hpp>

int main()
{
    mapnik::Map m(256,256);
    mapnik::load_map(m, "path/to/file.xml");
    m.zoom_all();
    mapnik::image_rgba8 im(256,256);
    mapnik::agg_renderer<mapnik::image_rgba8> ren(m, im);
    ren.apply();
    mapnik::save_to_file(im, "the_image.png");
    return 0;
}

CMakeLists:

cmake_minimum_required(VERSION 3.1.0)

project(MapnikTest)
find_package(mapnik REQUIRED)

add_executable(${PROJECT_NAME} map-renderer.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE mapnik::agg mapnik::mapnik)

CMake configures and generates makefile but it can't build the project:

user@user-GL73-8RD:~/Documents/Projects/mapnik-tests/build$ make
[ 50%] Building CXX object CMakeFiles/MapnikTest.dir/map-renderer.cpp.o
[100%] Linking CXX executable MapnikTest
/usr/bin/ld: CMakeFiles/MapnikTest.dir/map-renderer.cpp.o: warning: relocation against `_ZN6mapnik22MAPNIK_GEOGRAPHIC_PROJB5cxx11E' in read-only section `.text'
/usr/bin/ld: CMakeFiles/MapnikTest.dir/map-renderer.cpp.o: in function `main':
map-renderer.cpp:(.text+0x29): undefined reference to `mapnik::MAPNIK_GEOGRAPHIC_PROJ[abi:cxx11]'
/usr/bin/ld: map-renderer.cpp:(.text+0x3e): undefined reference to `mapnik::Map::Map(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/MapnikTest.dir/build.make:114: MapnikTest] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/MapnikTest.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

What could be a solution?

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
syat-cd
  • 11
  • 3
  • As all your error messages involves `cxx11`, [that question](https://stackoverflow.com/questions/33394934/converting-std-cxx11string-to-stdstring) would probably be relevant for you. – Tsyvarev Aug 29 '23 at 14:25
  • well. it actually worked. thank you! – syat-cd Aug 29 '23 at 15:17
  • On Stack Overflow we do NOT put a **solution** into the **question post**. Instead, an answer should be posted for provide a solution. In case of a duplicate closure, when the solution is contained in the answer to the duplicate question, no additional solution is needed to posted. Or you may write a *comment* where describe a solution in a few words plus provide a link to the helpful answer. – Tsyvarev Aug 29 '23 at 15:23

0 Answers0