lelongg / clipper-sys Goto Github PK
View Code? Open in Web Editor NEWBoolean operations on polygons (Clipper wrapper)
License: ISC License
Boolean operations on polygons (Clipper wrapper)
License: ISC License
I am trying to compile some basic clipper functions to WASM, to use as a bridge to Javascript. This is on a Mac M1, which might have something to do with the issue I am seeing.
(FYI, I have compiled various other Rust code and crates to WASM without issue on this same M1 computer, so I think I have the basics down. Just not sure how to address this compiler error.)
When using the default Mac clang compiler, I get this error:
[INFO]: ๐ Compiling to Wasm...
Compiling clipper-sys v0.7.2
The following warnings were emitted during compilation:warning: In file included from clipper/clipper.cpp:41:
warning: clipper/clipper.hpp:52:10: fatal error: 'vector' file not found
warning: #include
warning: ^~~~~~~~
warning: 1 error generated.error: failed to run custom build command for
clipper-sys v0.7.2
Caused by:
process didn't exit successfully:/Users/rhead/git/fvtt-test-ccw/intersections/target/release/build/clipper-sys-6c959c9fe2b70968/build-script-build
(exit status: 1)
--- stdout
cargo:rerun-if-changed=clipper
TARGET = Some("wasm32-unknown-unknown")
HOST = Some("aarch64-apple-darwin")
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/clipper.o" "-c" "clipper/clipper.cpp"
cargo:warning=In file included from clipper/clipper.cpp:41:
cargo:warning=clipper/clipper.hpp:52:10: fatal error: 'vector' file not found
cargo:warning=#include
cargo:warning= ^~~~~~~~
cargo:warning=1 error generated.
exit status: 1--- stderr
error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/clipper.o" "-c" "clipper/clipper.cpp" with args "clang" did not execute successfully (status code exit status: 1).
Error: Compiling your crate to WebAssembly failed
Caused by: failed to executecargo build
: exited with exit status: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
I would guess that clang is trying to compile "clipper/clipper.hpp" as a c file, not a c++ file. But if so, I don't know why, and don't know how to fix it.
I also tried installing gcc in homebrew, and then forced it to use that compiler instead, i.e, by passing environmental variables to the compile script: CC=/opt/homebrew/bin/gcc-11 CXX=/opt/homebrew/bin/g++-11 ./build_wasm.sh
I still get a compile error, albeit a different one:
[INFO]: ๐ Compiling to Wasm...
Compiling clipper-sys v0.7.2
error: failed to run custom build command forclipper-sys v0.7.2
Caused by:
process didn't exit successfully:/Users/rhead/git/fvtt-test-ccw/intersections/target/release/build/clipper-sys-6c959c9fe2b70968/build-script-build
(exit status: 101)
--- stdout
cargo:rerun-if-changed=clipper
TARGET = Some("wasm32-unknown-unknown")
HOST = Some("aarch64-apple-darwin")
CXX_wasm32-unknown-unknown = None
CXX_wasm32_unknown_unknown = None
TARGET_CXX = None
CXX = Some("/opt/homebrew/bin/g++-11")
CXXFLAGS_wasm32-unknown-unknown = None
CXXFLAGS_wasm32_unknown_unknown = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = None
running: "/opt/homebrew/bin/g++-11" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-Wall" "-Wextra" "-o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/clipper.o" "-c" "clipper/clipper.cpp"
exit status: 0
running: "/opt/homebrew/bin/g++-11" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-Wall" "-Wextra" "-o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/wrapper.o" "-c" "clipper/wrapper.cpp"
exit status: 0
AR_wasm32-unknown-unknown = None
AR_wasm32_unknown_unknown = None
TARGET_AR = None
AR = None
CROSS_COMPILE = None
running: "ar" "cq" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/libclipper.a" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/clipper.o" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/clipper/wrapper.o"
exit status: 0
running: "ar" "s" "/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out/libclipper.a"
exit status: 0
cargo:rustc-link-lib=static=clipper
cargo:rustc-link-search=native=/Users/rhead/git/fvtt-test-ccw/intersections/target/wasm32-unknown-unknown/release/build/clipper-sys-527f62cc4ff17778/out
CXXSTDLIB_wasm32-unknown-unknown = None
CXXSTDLIB_wasm32_unknown_unknown = None
TARGET_CXXSTDLIB = None
CXXSTDLIB = None
cargo:rustc-link-lib=stdc++--- stderr
thread 'main' panicked at 'not implemented: target_os: unknown, target_env: ', /Users/rhead/.cargo/registry/src/github.com-1ecc6299db9ec823/clipper-sys-0.7.2/build.rs:23:14
note: run withRUST_BACKTRACE=1
environment variable to display a backtrace
Error: Compiling your crate to WebAssembly failed
Caused by: failed to executecargo build
: exited with exit status: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
Any insights would be much appreciated! Thanks!
I'm getting a failure to build on an x86_64 mac, Macos 12.3.1.
It looks like it's not using the right C++ version when compiling:
cargo:warning=clipper/wrapper.cpp:201:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
cargo:warning= auto &polygon = polygons.polygons[i];
cargo:warning= ^
cargo:warning=clipper/wrapper.cpp:202:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
cargo:warning= auto paths_closed = get_polygon_paths(polygon);
cargo:warning= ^
cargo:warning=13 warnings and 1 error generated.
exit status: 1
--- stderr
error occurred: Command "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-arch" "x86_64" "-Wall" "-Wextra" "-o" "/Users/derek/workspace/creative/aoer-plotty-rs/target/debug/build/clipper-sys-aa4025f4709bc662/out/clipper/wrapper.o" "-c" "clipper/wrapper.cpp" with args "c++" did not execute successfully (status code exit status: 1).
I can get this to compile fairly easily with a one-line change:
armyofevilrobots@0271a5a
I do wonder if I am missing some obvious setup step though...
Hi, I noticed your lib wraps Angus Johnson clipping lib (unchanged since 2014?), and that seems to be the same lib that was used as the basis of Mapbox's wagyu. Moreover, Postgis has switched to Wagyu for their clipping needs as well. Would it make sense to migrate to Wagyu as it is far more recent and maintained? I am trying to re-implement some Postgis-based code in Rust, and clipping is a big part of that. Thanks!
This crate and geo-sys specify a license in the Cargo.toml, but have no license file in the repositories.
I think they should have clear license files and a CLA to ensure contributions are consistent with the license.
OS: Windows 10 x64
I'm attempting to offset a polygon, and am receiving a segfault when doing so. If LLDB is to be trusted, I believe this is due to size_t
not mapping correctly; looking at bindings.rs, size_t
ultimately resolves to u32
, whereas in C++ the size_t
is considered u64
(unsigned long long):
The failure is occurring here, I believe due to inflated count values as indicated in the second screenshot. This issue does not present when the same application is run in Linux.
In an issue related to the here requested extension it has been pointed out, that the offset operator alone can lead to disfigured polygons, which do not yield a valid area.
In order to overcome this problem I propose to extend this library to support the SimplifyPolygons
as well as the CleanPolygons
function of the clipper library. The use of this can be examined in the issue mentioned above.
Add wrapper function for the SimplifyPolygons
method.
Add wrapper function for the CleanPolygons
method.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.