0

I getting started on c++11 and tried to run some example code with boost geometry

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>

BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)


int main()
{
    typedef boost::tuple<double, double> point;
    typedef boost::geometry::model::polygon<point> polygon;

    polygon poly;
    boost::geometry::read_wkt("polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
        ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))", poly);

    polygon hull;
    boost::geometry::convex_hull(poly, hull);

    using boost::geometry::dsv;
    std::cout
        << "polygon: " << dsv(poly) << std::endl
        << "hull: " << dsv(hull) << std::endl
        ;


    return 0;
}

but i got following errors

/boost/include/boost/geometry/algorithms/detail/recalculate.hpp: In statischer Elementfunktion »static void boost::geometry::detail::recalculate::polygon_to_polygon::apply(Polygon1&,

const Polygon2&, const Strategy&)«: boost/include/boost/geometry/algorithms/detail/recalculate.hpp:145:24: Fehler: »it_source« is not defined

boost/include/boost/geometry/algorithms/detail/recalculate.hpp:146:24: Fehler: »it_dest« is not defined

Anyone has an idea why this is not working ?

Sry i forgot to add my System. I'm using 64Bit Mint 13 with GCC 4.6.3 and boost 1.55

thanks for your help

mloskot
  • 37,086
  • 11
  • 109
  • 136
Hunk
  • 479
  • 11
  • 33
  • 1
    Its working for me: boost 1.54, gcc 4.7.2 – Galimov Albert Jul 24 '14 at 15:32
  • 2
    Always when asking about error (compile or link or whatever), it's good to write, the compiler (include version and if there is using a non default library, the name) and the platform when the error occur (ex: GCC 4.9.0 32bits, Windows 8.1 or GCC 4.9.0 32bits with libc++, Windows 8.1, etc...) – NetVipeC Jul 24 '14 at 15:39
  • I'd suggest updating first. 4.6.3 is really old. – sehe Jul 25 '14 at 05:25
  • ok it is usefull to update on gcc 4.8 with ppa http://askubuntu.com/questions/271388/how-to-install-gcc-4-8-in-ubuntu-12-04-from-the-terminal. Or should i use gcc 4.7 which is in the ubuntu package system? And thank you for your help – Hunk Jul 25 '14 at 06:03

1 Answers1

1

Apparently your compiler

  • is C++11-challenged
  • is misconfigured

in such a way that BOOST_AUTO_TPL is not working:

    BOOST_AUTO_TPL(it_source, boost::begin(rings_source));
    BOOST_AUTO_TPL(it_dest, boost::begin(rings_dest));

On a c++11 compiler it would expand to

auto it_source = boost::begin(rings_source);
auto it_dest = boost::begin(rings_dest);

However, if you compile that in c++03 mode (e.g. without -std=c++11 on gcc/clang) you might get the error that it_source or it_dest aren't valid types (besides, the rest of the statements/declaration being malformed)

sehe
  • 374,641
  • 47
  • 450
  • 633
  • how i should define my compiler ? I only do gcc -std=c++0x main.cpp -I ~/boost/include. Without boost geometry i can use c++11 features like auto – Hunk Jul 25 '14 at 05:19
  • @Hunk it's usually all done at compiletime, "automagically". However, it is possible that the detection routines get it wrong on your platform. You can look at the supported compiler versions for Boost 1.55 or try upgrading your tool chian. – sehe Jul 25 '14 at 07:52
  • hi i updated gcc to 4.9.1 and have the same error. Do you have any ideas ? as flag i use gcc -std=c++11 or -std=c++0x is the same or? – Hunk Jul 28 '14 at 14:50