{"action":"created","issue":{"url":"https://api.github.com/repos/mapnik/mapnik/issues/3469","repository_url":"https://api.github.com/repos/mapnik/mapnik","labels_url":"https://api.github.com/repos/mapnik/mapnik/issues/3469/labels{/name}","comments_url":"https://api.github.com/repos/mapnik/mapnik/issues/3469/comments","events_url":"https://api.github.com/repos/mapnik/mapnik/issues/3469/events","html_url":"https://github.com/mapnik/mapnik/issues/3469","id":165780033,"number":3469,"title":"Errors building c++ program that uses mapnik as library","user":{"login":"acac97","id":8714848,"avatar_url":"https://avatars.githubusercontent.com/u/8714848?v=3","gravatar_id":"","url":"https://api.github.com/users/acac97","html_url":"https://github.com/acac97","followers_url":"https://api.github.com/users/acac97/followers","following_url":"https://api.github.com/users/acac97/following{/other_user}","gists_url":"https://api.github.com/users/acac97/gists{/gist_id}","starred_url":"https://api.github.com/users/acac97/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acac97/subscriptions","organizations_url":"https://api.github.com/users/acac97/orgs","repos_url":"https://api.github.com/users/acac97/repos","events_url":"https://api.github.com/users/acac97/events{/privacy}","received_events_url":"https://api.github.com/users/acac97/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-07-15T12:51:11Z","updated_at":"2016-07-19T11:49:26Z","closed_at":"2016-07-18T14:03:19Z","body":"So I'm facing next issue. I want to use mapnik c++ library in my program for generating map, but building it is a real nightmare. I made CMakeLists.txt for building my code, but I can't make it build successfully. When I activate demo mode in mapnik build folder and replace rundemo.cpp with my code everything works just fine. So what is different between my building technique and SCons one?\r\nHere is my CMakeLists.txt file:\r\n\r\n`\r\ncmake_minimum_required(VERSION 2.5)\r\nproject(map)\r\n\r\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11  \")\r\n\r\nset(SOURCE_FILES main.cpp)\r\nadd_executable(map-dev-test ${SOURCE_FILES})\r\n\r\ninclude_directories(/home/alexander/mapnik-3.x/mason_packages/.link/include)\r\ninclude_directories(/home/alexander/mapnik-3.x/include)\r\ninclude_directories(/home/alexander/mapnik-3.x/deps/mapbox/variant/include)\r\n\r\ninclude_directories(/home/alexander/mapnik-3.x/mason_packages/linux-x86_64/icu/55.1/include)\r\nlink_directories(/home/alexander/mapnik-3.x/mason_packages/linux-x86_64/icu/55.1/lib)\r\ntarget_link_libraries(map-dev-test libicudata.a)\r\ntarget_link_libraries(map-dev-test libicui18n.a)\r\ntarget_link_libraries(map-dev-test libicutest.a)\r\ntarget_link_libraries(map-dev-test libicutu.a)\r\ntarget_link_libraries(map-dev-test libicuuc.a)\r\n\r\nlink_directories(/home/alexander/mapnik-3.x/mason_packages/.link/lib)\r\n\r\nlink_directories(/home/alexander/mapnik-3.x/src)\r\ntarget_link_libraries(map-dev-test /home/alexander/mapnik-3.x/src/libmapnik.so.3.0)\r\ntarget_link_libraries(map-dev-test /home/alexander/mapnik-3.x/src/libmapnik.so)\r\n\r\ntarget_link_libraries(map-dev-test /lib/x86_64-linux-gnu/libz.so.1)\r\ntarget_link_libraries(map-dev-test /lib/x86_64-linux-gnu/libdl.so.2)\r\n`\r\n\r\nAlso here is main.cpp file:\r\n\r\n```c++\r\n#include <mapnik/map.hpp>\r\n#include <mapnik/layer.hpp>\r\n#include <mapnik/color_factory.hpp>\r\n#include <mapnik/datasource_cache.hpp>\r\n#include <mapnik/image.hpp>\r\n#include <mapnik/image_util.hpp>\r\n#include <mapnik/agg_renderer.hpp>\r\n#include <mapnik/rule.hpp>\r\n#include <mapnik/feature_type_style.hpp>\r\n#include <mapnik/symbolizer.hpp>\r\n\r\n#include <iostream>\r\n\r\nint main()\r\n{\r\n   using namespace mapnik;\r\n   datasource_cache::instance().register_datasources(\"/usr/local/lib/mapnik/input\");\r\n   Map m{800, 600};\r\n   m.set_background(parse_color(\"steelblue\"));\r\n   feature_type_style s;\r\n   s.reserve(1);\r\n   rule r;\r\n   polygon_symbolizer ps;\r\n   put(ps, keys::fill, parse_color(\"white\"));\r\n   r.append(std::move(ps));\r\n   s.add_rule(std::move(r));\r\n   m.insert_style(\"stil\", std::move(s));\r\n   parameters p;\r\n   p[\"inline\"] = \"id|wkt\\n1|POLYGON((1 1, 3 1, 1 3, 1 1))\";\r\n   p[\"type\"] = \"csv\";\r\n   layer l{\"Humboro\"};\r\n   l.set_datasource(datasource_cache::instance().create(p));\r\n   l.add_style(\"stil\");\r\n   m.add_layer(l);\r\n   m.zoom_to_box(box2d<double>(0, 0, 5, 5));\r\n   image_rgba8 im(600, 800);\r\n   agg_renderer<image_rgba8> ren(m, im);\r\n   ren.apply();\r\n   save_to_file(im, \"humboro.png\", \"png\");\r\n}\r\n```\r\n\r\nAnd this is error that I'm getting:\r\n\r\n`alexander@PC:~/mapnikCPPTest/bin$ cmake ..\r\n-- Configuring done\r\n-- Generating done\r\n-- Build files have been written to: /home/alexander/mapnikCPPTest/bin\r\nalexander@PC:~/mapnikCPPTest/bin$ make\r\n[100%] Building CXX object CMakeFiles/map-dev-test.dir/main.o\r\nIn file included from /home/alexander/mapnikCPPTest/main.cpp:4:0:\r\n/home/alexander/mapnik-3.x/include/mapnik/datasource_cache.hpp:67:35: warning: type attributes ignored after type is already defined [-Wattributes]\r\n extern template class MAPNIK_DECL singleton<datasource_cache, CreateStatic>;\r\n                                   ^\r\nIn file included from /home/alexander/mapnik-3.x/include/mapnik/attribute.hpp:28:0,\r\n                 from /home/alexander/mapnik-3.x/include/mapnik/symbolizer_base.hpp:34,\r\n                 from /home/alexander/mapnik-3.x/include/mapnik/rule.hpp:28,\r\n                 from /home/alexander/mapnik-3.x/include/mapnik/agg_renderer.hpp:30,\r\n                 from /home/alexander/mapnikCPPTest/main.cpp:7:\r\n/home/alexander/mapnik-3.x/include/mapnik/value.hpp:152:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]\r\n #pragma GCC diagnostic ignored \"-Wmismatched-tags\"\r\n                                ^\r\nLinking CXX executable map-dev-test\r\nCMakeFiles/map-dev-test.dir/main.o: In function `main':\r\nmain.cpp:(.text+0x2a8): undefined reference to `mapnik::rule::append(mapnik::util::variant<mapnik::point_symbolizer, mapnik::line_symbolizer, mapnik::line_pattern_symbolizer, mapnik::polygon_symbolizer, mapnik::polygon_pattern_symbolizer, mapnik::raster_symbolizer, mapnik::shield_symbolizer, mapnik::text_symbolizer, mapnik::building_symbolizer, mapnik::markers_symbolizer, mapnik::group_symbolizer, mapnik::debug_symbolizer, mapnik::dot_symbolizer>&&)'\r\ncollect2: error: ld returned 1 exit status\r\nmake[2]: *** [map-dev-test] Error 1\r\nmake[1]: *** [CMakeFiles/map-dev-test.dir/all] Error 2\r\nmake: *** [all] Error 2`\r\n\r\nSo what is wrong with my building method, and how can I get it to work? Also I can't find any documentation for using mapnik with c++, so if there is any please tell me about it."},"comment":{"url":"https://api.github.com/repos/mapnik/mapnik/issues/comments/233608677","html_url":"https://github.com/mapnik/mapnik/issues/3469#issuecomment-233608677","issue_url":"https://api.github.com/repos/mapnik/mapnik/issues/3469","id":233608677,"user":{"login":"artemp","id":59056,"avatar_url":"https://avatars.githubusercontent.com/u/59056?v=3","gravatar_id":"","url":"https://api.github.com/users/artemp","html_url":"https://github.com/artemp","followers_url":"https://api.github.com/users/artemp/followers","following_url":"https://api.github.com/users/artemp/following{/other_user}","gists_url":"https://api.github.com/users/artemp/gists{/gist_id}","starred_url":"https://api.github.com/users/artemp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artemp/subscriptions","organizations_url":"https://api.github.com/users/artemp/orgs","repos_url":"https://api.github.com/users/artemp/repos","events_url":"https://api.github.com/users/artemp/events{/privacy}","received_events_url":"https://api.github.com/users/artemp/received_events","type":"User","site_admin":false},"created_at":"2016-07-19T11:49:26Z","updated_at":"2016-07-19T11:49:26Z","body":"👍"}}
{"actor":{"display_login":"artemp"}}