Cannot compile a C++ Program due to Undefined Reference errors with Mapnik

113 views Asked by At

I installed mapnik 4.0.0 from source using cmake. Now Im trying to run C++ default example:

#define _GLIBCXX_USE_CXX11_ABI 0

#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, "/usr/share/renderd/example-map/mapnik.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;
}

with this line:

g++ map-renderer.cpp -o a.out -L/usr/local/lib -lmapnik

But I keep getting those errors:

g++ map-renderer.cpp -o a.out -L/usr/local/lib -lmapnik
/usr/bin/ld: /tmp/ccKF0om7.o: warning: relocation against `_ZN6mapnik22MAPNIK_GEOGRAPHIC_PROJE' in read-only section `.text'
/usr/bin/ld: /tmp/ccKF0om7.o: in function `main':
map-renderer.cpp:(.text+0x29): undefined reference to `mapnik::MAPNIK_GEOGRAPHIC_PROJ'
/usr/bin/ld: map-renderer.cpp:(.text+0x3e): undefined reference to `mapnik::Map::Map(int, int, std::string const&)'
/usr/bin/ld: map-renderer.cpp:(.text+0xc1): undefined reference to `mapnik::load_map(mapnik::Map&, std::string const&, bool, std::string)'
/usr/bin/ld: map-renderer.cpp:(.text+0x1cd): undefined reference to `void mapnik::save_to_file<mapnik::image<mapnik::rgba8_t> >(mapnik::image<mapnik::rgba8_t> const&, std::string const&)'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status

What could be the reason for those errors? I tried building with CMake, tried running default bootstrap.sh script but the error keeps appearing.

Looks like with order of libraries included everything should be okay.

p.s. Mapnik source: https://github.com/mapnik/mapnik

0

There are 0 answers