我在使用 mapnik 库 (c++) 时遇到了问题。我已经使用 brew 在 Mac(m1) 上安装了 mapnik,并将其添加到 cmake 项目中。
CMakeLists.txt代码:
cmake_minimum_required(VERSION 3.21)
project(test_mapnik)
set(CMAKE_CXX_STANDARD 14)
add_executable(test_mapnik main.cpp)
target_include_directories(test_mapnik PRIVATE lib/mapnik/3.1.0_17/include) target_include_directories(test_mapnik PRIVATE lib/boost/1.81.0_1/include)
target_link_libraries(test_mapnik ${CMAKE_CURRENT_SOURCE_DIR}/lib/mapnik/3.1.0_17/lib/libmapnik.dylib)
之后我从 (https://mapnik.org) 粘贴代码示例
#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;
}
我得到一个错误:
libc++abi: terminating with uncaught exception of type mapnik::config_error: Could not create datasource for type: 'shape' (no datasource plugin directories have been successfully registered) encountered during parsing of layer 'world' in Layer of '../file.xml'
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
我不知道该怎么办。