mapbox / mapnik-vector-tile

Mapnik implemention of Mapbox Vector Tile specification
BSD 3-Clause "New" or "Revised" License
553 stars 117 forks source link

mapnik-vector-tile 1.2.1 fails to to build due to undefined references #217

Closed sebastic closed 8 years ago

sebastic commented 8 years ago

I've been trying to build mapnik-vector-tile 1.2.0 & 1.2.1 since they were released, but the builds fail due to undefined references similar to those reported in #187:

  g++  -Wl,-z,relro -o Release/tests -Wl,--start-group ./Release/obj.target/tests/test/test_main.o ./Release/obj.target/tests/test/raster_tile.o ./Release/obj.target/tests/test/system/round_trip_simplification.o ./Release/obj.target/tests/test/system/round_trip_fill_type.o ./Release/obj.target/tests/test/system/round_trip.o ./Release/obj.target/tests/test/system/remove_repeated_point.o ./Release/obj.target/tests/test/system/encode_and_decode.o ./Release/obj.target/tests/test/system/encode_and_datasource_decode.o ./Release/obj.target/tests/test/system/processor_and_datasource.o ./Release/obj.target/tests/test/geometry_visual_test.o ./Release/obj.target/tests/test/clipper_test.o ./Release/obj.target/tests/test/vector_tile_rasterize.o ./Release/obj.target/tests/test/unit/composite/vector.o ./Release/obj.target/tests/test/unit/load/merge.o ./Release/obj.target/tests/test/unit/is_valid/feature_is_valid.o ./Release/obj.target/tests/test/unit/is_valid/value_is_valid.o ./Release/obj.target/tests/test/unit/tile_impl/tile.o ./Release/obj.target/tests/test/unit/decoding/polygon_scaling.o ./Release/obj.target/tests/test/unit/decoding/polygon.o ./Release/obj.target/tests/test/unit/decoding/point.o ./Release/obj.target/tests/test/unit/decoding/linestring.o ./Release/obj.target/tests/test/unit/compression/compression.o ./Release/obj.target/tests/test/unit/encoding/point_pbf.o ./Release/obj.target/tests/test/unit/encoding/geometry_to_feature_pbf.o ./Release/obj.target/tests/test/unit/encoding/polygon_pbf.o ./Release/obj.target/tests/test/unit/encoding/linestring_pbf.o ./Release/obj.target/tests/test/unit/datasource-pbf/from_layer.o ./Release/obj.target/tests/test/vector_tile_pbf.o ./Release/obj.target/tests/test/vector_tile_projection.o ./Release/obj.target/tests/test/utils/round_trip.o ./Release/obj.target/tests/test/utils/decoding_util.o ./Release/obj.target/tests/test/utils/geom_to_wkt.o ./Release/obj.target/tests/test/utils/encoding_util.o ./Release/obj.target/tests/test/test_utils.o ./Release/obj.target/tests/test/vector_tile.o ./Release/obj.target/gyp/libmapnik_vector_tile_impl.a ./Release/obj.target/gyp/libvector_tile.a -Wl,--end-group -L/usr/lib -lmapnik -L/usr/lib/x86_64-linux-gnu -Wl,-z,relro -Wl,-z,now -g0 -pthread -lmapnik-wkt -lmapnik-json -lboost_filesystem -lboost_regex -lcairo -lpng -lproj -ltiff -lwebp -lxml2 -licui18n -lboost_system -lharfbuzz -ljpeg -licuuc -lfreetype -lz -ldl -lprotobuf-lite
In file included from ../bin/vtile-fuzz.cpp:1:0:
../src/vector_tile_geometry_clipper.hpp: In function 'ClipperLib::PolyFillType mapnik::vector_tile_impl::detail::get_angus_fill_type(mapnik::vector_tile_impl::polygon_fill_type)':
../src/vector_tile_geometry_clipper.hpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
./Release/obj.target/gyp/../mapnik_vector_tile_impl/src/vector_tile_featureset_pbf.o: In function `mapnik::vector_tile_impl::tile_featureset_pbf<mapnik::filter_at_point>::next()':
./build/../src/vector_tile_featureset_pbf.ipp:273: undefined reference to `mapnik::geometry::geometry<double> mapnik::vector_tile_impl::decode_geometry<double>(mapnik::vector_tile_impl::GeometryPBF&, int, unsigned int, double, double, double, double, mapnik::box2d<double> const&)'
./build/../src/vector_tile_featureset_pbf.ipp:294: undefined reference to `mapnik::geometry::geometry<double> mapnik::vector_tile_impl::decode_geometry<double>(mapnik::vector_tile_impl::GeometryPBF&, int, unsigned int, double, double, double, double, mapnik::box2d<double> const&)'
./Release/obj.target/gyp/../mapnik_vector_tile_impl/src/vector_tile_featureset_pbf.o: In function `mapnik::vector_tile_impl::tile_featureset_pbf<mapnik::filter_in_box>::next()':
./build/../src/vector_tile_featureset_pbf.ipp:273: undefined reference to `mapnik::geometry::geometry<double> mapnik::vector_tile_impl::decode_geometry<double>(mapnik::vector_tile_impl::GeometryPBF&, int, unsigned int, double, double, double, double, mapnik::box2d<double> const&)'
./build/../src/vector_tile_featureset_pbf.ipp:294: undefined reference to `mapnik::geometry::geometry<double> mapnik::vector_tile_impl::decode_geometry<double>(mapnik::vector_tile_impl::GeometryPBF&, int, unsigned int, double, double, double, double, mapnik::box2d<double> const&)'
collect2: error: ld returned 1 exit status
gyp/tests.target.mk:255: recipe for target 'Release/tests' failed

I'm at a loss at what is causing this and how to fix it. Not having mapnik-vector-tile >= 1.2.0 is preventing the update of node-mapnik to 3.5.13, and both need to be rebuild with Mapnik 3.0.12 which is required for Boost 1.61 support.

It seems the changes to decode_geometry() in version 1.2.0 are related, though the first prototype in src/vector_tile_geometry_decoder.hpp should match:

 67 template <typename value_type>
 68 MAPNIK_VECTOR_INLINE mapnik::geometry::geometry<value_type> decode_geometry(GeometryPBF & paths,
 69                                                                             std::int32_t geom_type,
 70                                                                             unsigned version,
 71                                                                             value_type tile_x,
 72                                                                             value_type tile_y,
 73                                                                             double scale_x,
 74                                                                             double scale_y,
 75                                                                             mapnik::box2d<double> const& bbox);

Full buildlog: mapnik-vector-tile_1.2.1+dfsg-1_amd64-build.txt

springmeyer commented 8 years ago

Thanks for the report @sebastic - We'll take a look, if not today then early next week.

springmeyer commented 8 years ago

@sebastic I think I see the problem. Can you try this patch:

diff --git a/src/vector_tile_geometry_decoder.cpp b/src/vector_tile_geometry_decoder.cpp
index 07cfc39..528f6f5 100644
--- a/src/vector_tile_geometry_decoder.cpp
+++ b/src/vector_tile_geometry_decoder.cpp
@@ -22,6 +22,22 @@ template mapnik::geometry::geometry<std::int64_t> decode_geometry<std::int64_t>(
                                                                                 std::int64_t tile_y,
                                                                                 double scale_x, 
                                                                                 double scale_y);
+template mapnik::geometry::geometry<double> decode_geometry<double>(GeometryPBF & paths, 
+                                                                    int32_t geom_type, 
+                                                                    unsigned version,
+                                                                    double tile_x,
+                                                                    double tile_y,
+                                                                    double scale_x, 
+                                                                    double scale_y,
+                                                                    mapnik::box2d<double> const& bbox);
+template mapnik::geometry::geometry<std::int64_t> decode_geometry<std::int64_t>(GeometryPBF & paths, 
+                                                                                int32_t geom_type, 
+                                                                                unsigned version,
+                                                                                std::int64_t tile_x,
+                                                                                std::int64_t tile_y,
+                                                                                double scale_x, 
+                                                                                double scale_y,
+                                                                                mapnik::box2d<double> const& bbox);

 } // end ns vector_tile_impl
sebastic commented 8 years ago

Thanks for the patch, the additional templates did the trick.

In retrospect I'm somewhat ashamed that I did not notice the discrepancy between the .cpp & .hpp files.

springmeyer commented 8 years ago

Okay, thank you for testing/confirming. I think this is a bug but it is only happening on some systems because of how different linkers strip symbols. I will commit the fix now. Thanks again for finding this!