Skip to content

Compilation Error with Clipper Backend: boost::geometry::model::polygon not found in boost_alg.hpp #65

@sherlcrow

Description

@sherlcrow

I encountered a compilation error when trying to use libnest2d with the Clipper backend after installing it system-wide using CMake.

  1. Environment:

OS: TencentOS (Based on RHEL/CentOS)
Compiler: GCC (via devtoolset-7)
Boost: Installed via yum install boost-devel (Version: 1.53.0-25.el7)
Polyclipping: Installed via yum install polyclipping-devel (Version: 6.4.2-14.el7)

  1. I have finished configuer:
    mkdir build && cd build
    cmake .. -DLIBNEST2D_HEADER_ONLY=OFF -DCMAKE_INSTALL_PREFIX=/usr/local -DRP_ENABLE_DOWNLOADING=ON
    cmake --build . --target install

  2. Create a simple test file (main.cpp) that includes libnest2d with the Clipper backend defined:
    #define LIBNEST2D_GEOMETRIES_clipper
    #define LIBNEST2D_OPTIMIZER_nlopt
    #include <libnest2d/libnest2d.hpp>

int main() {
// Example usage code here
return 0;
}

  1. Attempt to compile the test file:
    In file included from /usr/local/include/libnest2d/backends/clipper/geometries.hpp:352:0,
    from /usr/local/include/libnest2d/libnest2d.hpp:7,
    from main.cpp:11:
    /usr/local/include/libnest2d/utils/boost_alg.hpp: In function ‘std::string libnest2d::shapelike::serialize(const S&, double) [with libnest2d::Formats = (libnest2d::Formats)1; S = ClipperLib::Polygon; std::string = std::basic_string]’:
    /usr/local/include/libnest2d/utils/boost_alg.hpp:441:29: error: ‘polygon’ in namespace ‘boost::geometry::model’ does not name a template type
    using Polygonf = model::polygon;
    ^~~~~~~
    /usr/local/include/libnest2d/utils/boost_alg.hpp:443:5: error: ‘Polygonf’ has not been declared
    Polygonf::ring_type ring;
    ^~~~~~~~
    /usr/local/include/libnest2d/utils/boost_alg.hpp:444:5: error: ‘Polygonf’ has not been declared
    Polygonf::inner_container_type holes;
    ^~~~~~~~
    /usr/local/include/libnest2d/utils/boost_alg.hpp:445:5: error: ‘ring’ was not declared in this scope
    ring.reserve(shapelike::contourVertexCount(sh));
    ^~~~
    [... many more boost::geometry related errors follow ...]

  2. Question:
    Is there a specific minimum/maximum version of Boost required for the Clipper backend to function correctly with the installed method? Or is this a known compatibility issue with the interaction between Boost 1.60.0, Polyclipping 6.4.2, and the current libnest2d code's use of boost::geometry algorithms on Clipper types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions