mapnik-vector-tile: vector_tile.pb.h:12:2: error: #error This file was generated by a newer version of protoc

Hi, While I tried to make I faced this error

In file included from Release/obj/gen/vector_tile.pb.cc:5:0: Release/obj/gen/vector_tile.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is

I tried both protobuf 3.3.0 and protobuf 3.4.1 but there was not any change, where am I doing wrong?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 34 (14 by maintainers)

Most upvoted comments

@am2222 for some reason the vector tile you are creating is not proper, so this is something during your creation process.

If you had a std::string variable named buffer (your vector tile) you would do the following to go the other way back to an image.

int x = 0;
int y = 0;
int z = 0;
protozero::pbf_reader pbf_layer(buffer);
// Create datasource
std::shared_ptr<mapnik::vector_tile_impl::tile_datasource_pbf> ds
      = std::make_shared<mapnik::vector_tile_impl::tile_datasource_pbf>(pbf_layer,x,y,z);

// Create map
mapnik::Map map(256,256,"+init=epsg:3857");
// Load XML with style
mapnik::load_map(map,"/home/m/vectorTiles/mapnik-vector-tile-3.0.x/test/data/polygon-style.xml");

// Create layer
mapnik::layer lyr2("layer",map.srs());
lyr2.set_datasource(ds);
lyr2.add_style("style"); // name of style from xml

// Add layer to map
map.add_layer(lyr2);
map.zoom_all();

// Output image setup
mapnik::image_rgba8 im(map.width(),map.height());

// create renderer and run it
mapnik::agg_renderer<mapnik::image_rgba8> rend(map,im);
rend.apply();

// save updated image to file path
mapnik::save_to_file(im,"rasterize-expected-1.png","png32");
tile.ParseFromString

That function and that part of the code are simply convience functions that we have using from libprotobuf and its created header that I told you we don’t need. If you look at the test case example code I linked after that short set of code that I outlined above all the rest is simply checking the test results. You simply need the out_tile.get_buffer() <-- the is the resulting vector tile.

Use the agg from mapnik: https://github.com/mapnik/mapnik/tree/master/deps/agg If you have mapnik installed correctly, I suggest you use mapnik-config

For example:

mapnik-config --libs

or

mapnik-config --includes

@am2222 Have you seen https://github.com/mapbox/tippecanoe ?

Some notes on your code here – you have a lot going on here you don’t need.

First you have no need for #include <vector_tile.pb.h> – this is the protobuffer stuff we use in our tests only here, you see it sprinkled elsewhere because sometime in the past we moved from libprotobuf -> protozero. Protozero is our specially designed header only library for parsing protobufs and its a lot faster then libprotobuf from google. Drop all the google protobuf code.

You really just need to do something like this - https://github.com/mapbox/mapnik-vector-tile/blob/master/test/vector_tile.cpp#L50-L58

    unsigned tile_size = 4096;
    mapnik::Map tile_map(tile_size, tile_size, "+init=epsg:3857");
    mapnik::load_map(tile_map, style_path, true);
    mapnik::vector_tile_impl::processor ren(tile_map);
    int x = 0;
    int y = 0;
    int z = 0;
    mapnik::vector_tile_impl::tile out_tile = ren.create_tile(x,y,z,tile_size);
    std::string buffer = out_tile.get_buffer();

@am2222 it is a legacy of the library originally being designed as a header only library, but due to compile times was split out into hpp and ipp files. The library still operates as a header only library for use typically. You can see how this works somewhat at the bottom of hpp files: https://github.com/mapbox/mapnik-vector-tile/blob/master/src/vector_tile_processor.hpp#L209-L211

Just write your C++ code and include the hpp files you need and it works.

@am2222 yes, by default the make instruction sets a PATH variable that should include your path to a bin in the mason_packages path for protoc.

PATH="`pwd`/mason_packages/.link/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" \

I am wondering if perhaps you have a local protoc installed and this is causing problems.

For example locally for me:

mthompson@flippmoke:~/src/mapnik-vector-tile$ which protoc
/Users/mthompson/src/mapnik-vector-tile/mason_packages/.link/bin/protoc

I wonder if you are pulling back a locally installed protoc in this step rather then ours for some reason.

Also these can be your friends sometime:

make clean

or

make distclean

Take a look into Release/obj/gen/vector_tile.pb.h. Also check apt search protobuf-compiler.

I remember I was also facing this error, but cannot remember what was the culprit.

@am2222, what is the version in your vector_tile.pb.h? Cannot there be some conflict with protobuf-compiler from your system?

I see this in my vector_tile.pb.h, for example:

#if GOOGLE_PROTOBUF_VERSION < 3000000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please update
#error your headers.
#endif
#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please
#error regenerate this file with a newer version of protoc.
#endif

@am2222 could you provide the entire log after you run make, what version of Linux? I will attempt to replicate on a docker image if I can.

@am2222 what OS are you using, does running make simply not work. In MVT - only for the tests do we use protobuf library directly.