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?