Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on OSX -DENABLE_DATA_TOOLS=ON raising errors in GEOS #2021

Closed
TimMcCauley opened this issue Nov 2, 2019 · 7 comments
Closed

Building on OSX -DENABLE_DATA_TOOLS=ON raising errors in GEOS #2021

TimMcCauley opened this issue Nov 2, 2019 · 7 comments

Comments

@TimMcCauley
Copy link
Contributor

Greetings Valhalla authors,

I am having difficulties trying to build Valhalla on OS X 10.14.6 when setting ENABLE_DATA_TOOLS=ON. Without the build works fine:

cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_PYTHON_BINDINGS=Off -DBUILD_SHARED_LIBS=ON -DENABLE_DATA_TOOLS=OFF -DENABLE_SERVICES=ON -DBoost_USE_STATIC_LIBS=ON -DProtobuf_USE_STATIC_LIBS=ON -DLZ4_USE_STATIC_LIBS=ON
cd ..
make -C build -j4

however when setting ENABLE_DATA_TOOLS=ON it will raise a couple of GEOS errors:

[ 80%] Building CXX object CMakeFiles/valhalla_build_connectivity.dir/src/mjolnir/valhalla_build_connectivity.cc.o
In file included from /Users/neilmccauley/Workspaces/valhalla/src/mjolnir/valhalla_build_admins.cc:21:
/usr/local/include/geos/geom/Geometry.h:26:3: warning: "The GEOS C++ API is unstable, please use the C API instead" [-W#warnings]
# warning "The GEOS C++ API is unstable, please use the C API instead"
  ^
/usr/local/include/geos/geom/Geometry.h:27:3: warning: "HINT: #include geos_c.h" [-W#warnings]
# warning "HINT: #include geos_c.h"
  ^
/Users/neilmccauley/Workspaces/valhalla/src/mjolnir/valhalla_build_admins.cc:162:39: error: no matching member function for call to 'createPolygon'
      polys[totalpolys].polygon = gf->createPolygon(gf->createLinearRing(pline->getCoordinates()), 0);
                                  ~~~~^~~~~~~~~~~~~
/usr/local/include/geos/geom/GeometryFactory.h:271:14: note: candidate function not viable: no known conversion from 'std::unique_ptr<LinearRing>' to 'geos::geom::LinearRing *' for
      1st argument
    Polygon* createPolygon(LinearRing* shell,
             ^
/usr/local/include/geos/geom/GeometryFactory.h:276:30: note: candidate function not viable: no known conversion from 'int' to 'std::vector<std::unique_ptr<LinearRing> >' for 2nd
      argument
    std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
                             ^
/usr/local/include/geos/geom/GeometryFactory.h:280:14: note: candidate function not viable: no known conversion from 'std::unique_ptr<LinearRing>' to 'const geos::geom::LinearRing'
      for 1st argument
    Polygon* createPolygon(const LinearRing& shell,
             ^
/usr/local/include/geos/geom/GeometryFactory.h:274:30: note: candidate function not viable: requires single argument 'shell', but 2 arguments were provided
    std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell) const;
                             ^
/usr/local/include/geos/geom/GeometryFactory.h:268:30: note: candidate function not viable: requires 0 arguments, but 2 were provided
    std::unique_ptr<Polygon> createPolygon() const;
                             ^
/Users/neilmccauley/Workspaces/valhalla/src/mjolnir/valhalla_build_admins.cc:163:32: error: assigning to 'geos::geom::LinearRing *' from incompatible type
      'std::unique_ptr<LinearRing>'
      polys[totalpolys].ring = gf->createLinearRing(pline->getCoordinates());
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/neilmccauley/Workspaces/valhalla/src/mjolnir/valhalla_build_admins.cc:228:25: error: no matching member function for call to 'createPolygon'
      Polygon* poly(gf->createPolygon(polys[i].ring, interior.release()));
                    ~~~~^~~~~~~~~~~~~
/usr/local/include/geos/geom/GeometryFactory.h:271:14: note: candidate function not viable: no known conversion from 'std::__1::unique_ptr<std::__1::vector<geos::geom::Geometry *,
      std::__1::allocator<geos::geom::Geometry *> >, std::__1::default_delete<std::__1::vector<geos::geom::Geometry *, std::__1::allocator<geos::geom::Geometry *> > > >::pointer'
      (aka 'std::__1::vector<geos::geom::Geometry *, std::__1::allocator<geos::geom::Geometry *> > *') to 'std::vector<LinearRing *> *' for 2nd argument
    Polygon* createPolygon(LinearRing* shell,
             ^
/usr/local/include/geos/geom/GeometryFactory.h:276:30: note: candidate function not viable: no known conversion from 'geos::geom::LinearRing *' to 'std::unique_ptr<LinearRing>' for
      1st argument
    std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell,
                             ^
/usr/local/include/geos/geom/GeometryFactory.h:280:14: note: candidate function not viable: no known conversion from 'geos::geom::LinearRing *' to 'const geos::geom::LinearRing' for
      1st argument; dereference the argument with *
    Polygon* createPolygon(const LinearRing& shell,
             ^
/usr/local/include/geos/geom/GeometryFactory.h:274:30: note: candidate function not viable: requires single argument 'shell', but 2 arguments were provided
    std::unique_ptr<Polygon> createPolygon(std::unique_ptr<LinearRing> && shell) const;
                             ^
/usr/local/include/geos/geom/GeometryFactory.h:268:30: note: candidate function not viable: requires 0 arguments, but 2 were provided
    std::unique_ptr<Polygon> createPolygon() const;
                             ^
/Users/neilmccauley/Workspaces/valhalla/src/mjolnir/valhalla_build_admins.cc:459:19: error: no member named 'add' in 'geos::geom::CoordinateSequence'
          coords->add(c, 0);
          ~~~~~~  ^
2 warnings and 4 errors generated.
make[2]: *** [CMakeFiles/valhalla_build_admins.dir/src/mjolnir/valhalla_build_admins.cc.o] Error 1
make[1]: *** [CMakeFiles/valhalla_build_admins.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Does anyone have an idea what's going on here? I have followed the instructions in the README and from the circle ci config.

My geos version running is installed via homebrew:

> $ brew list geos                                                                                                                                              ⬡ 10.17.0 [±master ✓]
/usr/local/Cellar/geos/3.8.0/bin/geos-config
/usr/local/Cellar/geos/3.8.0/include/geos/ (409 files)
/usr/local/Cellar/geos/3.8.0/include/ (2 files)
/usr/local/Cellar/geos/3.8.0/lib/libgeos-3.8.0.dylib
/usr/local/Cellar/geos/3.8.0/lib/libgeos_c.1.dylib
/usr/local/Cellar/geos/3.8.0/lib/python3.7/ (4 files)
/usr/local/Cellar/geos/3.8.0/lib/ (4 other files)

Any help would be greatly appreciated. Thank you.

@TimMcCauley
Copy link
Contributor Author

@drewda do you have any ideas by any chance?

@kevinkreiser
Copy link
Member

@TimMcCauley different geos versions make changes to their API and the code doesnt detect all of the variants. We have a little bit of code in there at the moment that tries to work around certain versions of geos but apparently not all 😄 we'll need to look into the geos 3.8.0 docs to see where our cheese got moved to and then see how we could make our code also target that version as well

@TimMcCauley
Copy link
Contributor Author

@kevinkreiser thank you a bunch, I tried an older version of geos with a little workaround via brew which seemed to work. If one is running into this issue, I recommend to try [email protected]

https://github.com/Homebrew/homebrew-core/commits/master/Formula/geos.rb

which can be installed this way:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/03ee052b303b79ceaada49c420a6619c794ccbec/Formula/geos.rb

consider as closed for now!

@TimMcCauley
Copy link
Contributor Author

TimMcCauley commented Nov 4, 2019

.. and then you might get this error OSGeo/homebrew-osgeo4mac#174

> $ ../cmake-build-debug/valhalla_build_tiles -c valhalla.json ../files/liechtenstein-latest.osm.pbf

dyld: Library not loaded: /usr/local/opt/proj/lib/libproj.12.dylib
  Referenced from: /usr/local/opt/libspatialite/lib/libspatialite.7.dylib
  Reason: image not found

which I resolved with this symlink (probably super hacky... but...)

ln -s /usr/local/opt/proj/lib/libproj.15.dylib /usr/local/opt/proj/lib/libproj.12.dylib

or w/e versions your error message is yielding..

@purew
Copy link
Contributor

purew commented Nov 5, 2019

The library itself suggests using the C-api rather than the C++ bindings for api stability. Would it be a large change for us to simply use the more stable C-api?

@nilsnolde
Copy link
Member

For future reference: had the same problem on Ubuntu 18.04. If you have the PPA http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu in your apt lists (not recommended really, always ran into trouble with this; rather install from source if you need dev versions), it will have installed the 3.8.x version of GEOS C++ lib.

You can check and amend:

# check libgeos installation(s)
dpkg -l 'libgeos++-dev'
# if > 3.7, then remove
sudo apt-get purge libgeos++-dev
# Install a version from a stable repository (here the current one from `bionic/universe`)
sudo apt-get install libgeos++-dev=3.6.2-1build2 

@purew
Copy link
Contributor

purew commented Dec 6, 2019

Similar with Archlinux. Downgrade to a previous geos 3.7 for a temporary solution:

cd /var/cache/pacman
pacman -U geos-3.7.2-1-x86_64.pkg.tar.xz  # Or whichever patch release is in your cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants