twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.92k stars 149 forks source link

Fails to compile and doesn't generate a useful error message #36

Closed dralley closed 5 years ago

dralley commented 5 years ago

My platform is Fedora 30 with OpenCV 3.4.4, gcc 9.1.1 and I'm using the latest git revision https://github.com/twistedfall/opencv-rust/commit/b44eaa188506b06a7ea0110f1c29b46216445d75. This is what happens when I try to build the library:

[dalley@localhost opencv-rust]$ cargo build
   Compiling opencv v0.11.0 (/home/dalley/Devel/opencv-rust)
error: failed to run custom build command for `opencv v0.11.0 (/home/dalley/Devel/opencv-rust)`
process didn't exit successfully: `/home/dalley/Devel/opencv-rust/target/debug/build/opencv-4f0dc15973bad0e9/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=native=/usr/lib64
cargo:rustc-link-lib=opencv_shape
cargo:rustc-link-lib=opencv_stitching
cargo:rustc-link-lib=opencv_superres
cargo:rustc-link-lib=opencv_videostab
cargo:rustc-link-lib=opencv_aruco
cargo:rustc-link-lib=opencv_bgsegm
cargo:rustc-link-lib=opencv_bioinspired
cargo:rustc-link-lib=opencv_ccalib
cargo:rustc-link-lib=opencv_cvv
cargo:rustc-link-lib=opencv_dnn_objdetect
cargo:rustc-link-lib=opencv_dpm
cargo:rustc-link-lib=opencv_face
cargo:rustc-link-lib=opencv_photo
cargo:rustc-link-lib=opencv_freetype
cargo:rustc-link-lib=opencv_fuzzy
cargo:rustc-link-lib=opencv_hdf
cargo:rustc-link-lib=opencv_hfs
cargo:rustc-link-lib=opencv_img_hash
cargo:rustc-link-lib=opencv_line_descriptor
cargo:rustc-link-lib=opencv_optflow
cargo:rustc-link-lib=opencv_reg
cargo:rustc-link-lib=opencv_rgbd
cargo:rustc-link-lib=opencv_saliency
cargo:rustc-link-lib=opencv_stereo
cargo:rustc-link-lib=opencv_structured_light
cargo:rustc-link-lib=opencv_viz
cargo:rustc-link-lib=opencv_phase_unwrapping
cargo:rustc-link-lib=opencv_surface_matching
cargo:rustc-link-lib=opencv_tracking
cargo:rustc-link-lib=opencv_datasets
cargo:rustc-link-lib=opencv_text
cargo:rustc-link-lib=opencv_dnn
cargo:rustc-link-lib=opencv_video
cargo:rustc-link-lib=opencv_plot
cargo:rustc-link-lib=opencv_ml
cargo:rustc-link-lib=opencv_ximgproc
cargo:rustc-link-lib=opencv_xobjdetect
cargo:rustc-link-lib=opencv_objdetect
cargo:rustc-link-lib=opencv_calib3d
cargo:rustc-link-lib=opencv_features2d
cargo:rustc-link-lib=opencv_highgui
cargo:rustc-link-lib=opencv_videoio
cargo:rustc-link-lib=opencv_imgcodecs
cargo:rustc-link-lib=opencv_flann
cargo:rustc-link-lib=opencv_xphoto
cargo:rustc-link-lib=opencv_imgproc
cargo:rustc-link-lib=opencv_core
cargo:rustc-link-search=native=/usr/share/OpenCV/3rdparty/lib
cargo:rustc-link-search=native=/usr/lib64
cargo:rerun-if-changed=hdr_parser.py
cargo:rerun-if-changed=gen_rust.py
OpenCV lives in /usr/include/opencv2
Generating code in /home/dalley/Devel/opencv-rust/target/debug/build/opencv-76036d7842db50fa/out
Generating module 'core_detect' from headers:
    /usr/include/opencv2/core_detect.hpp
Error at /usr/include/opencv2/core_detect.hpp:27
Generating module 'cvv' from headers:
    /usr/include/opencv2/cvv.hpp
    /usr/include/opencv2/cvv/call_meta_data.hpp
    /usr/include/opencv2/cvv/cvv.hpp
    /usr/include/opencv2/cvv/debug_mode.hpp
    /usr/include/opencv2/cvv/dmatch.hpp
    /usr/include/opencv2/cvv/filter.hpp
    /usr/include/opencv2/cvv/final_show.hpp
    /usr/include/opencv2/cvv/show_image.hpp
Generating module 'face' from headers:
    /usr/include/opencv2/face.hpp
    /usr/include/opencv2/face/bif.hpp
    /usr/include/opencv2/face/face_alignment.hpp
    /usr/include/opencv2/face/facemark.hpp
    /usr/include/opencv2/face/facemarkAAM.hpp
    /usr/include/opencv2/face/facemarkLBF.hpp
    /usr/include/opencv2/face/facemark_train.hpp
    /usr/include/opencv2/face/facerec.hpp
    /usr/include/opencv2/face/mace.hpp
    /usr/include/opencv2/face/predict_collector.hpp
Generating module 'dnn' from headers:
    /usr/include/opencv2/dnn.hpp
    /usr/include/opencv2/dnn/all_layers.hpp
    /usr/include/opencv2/dnn/dict.hpp
    /usr/include/opencv2/dnn/dnn.hpp
    /usr/include/opencv2/dnn/layer.hpp
    /usr/include/opencv2/dnn/shape_utils.hpp
Generating module 'features2d' from headers:
    /usr/include/opencv2/features2d.hpp
    /usr/include/opencv2/features2d/features2d.hpp
    /usr/include/opencv2/features2d/hal/interface.h
Generating module 'imgproc' from headers:
    /usr/include/opencv2/imgproc.hpp
    /usr/include/opencv2/imgproc/hal/interface.h
    /usr/include/opencv2/imgproc/imgproc.hpp
Generating module 'dpm' from headers:
    /usr/include/opencv2/dpm.hpp
Generating module 'freetype' from headers:
    /usr/include/opencv2/freetype.hpp
Generating module 'line_descriptor' from headers:
    /usr/include/opencv2/line_descriptor.hpp
    /usr/include/opencv2/line_descriptor/descriptor.hpp
Generating module 'fuzzy' from headers:
    /usr/include/opencv2/fuzzy.hpp
    /usr/include/opencv2/fuzzy/fuzzy_F0_math.hpp
    /usr/include/opencv2/fuzzy/fuzzy_F1_math.hpp
    /usr/include/opencv2/fuzzy/fuzzy_image.hpp
    /usr/include/opencv2/fuzzy/types.hpp
Generating module 'hdf' from headers:
    /usr/include/opencv2/hdf.hpp
    /usr/include/opencv2/hdf/hdf5.hpp
Generating module 'shape' from headers:
    /usr/include/opencv2/shape.hpp
    /usr/include/opencv2/shape/emdL1.hpp
    /usr/include/opencv2/shape/hist_cost.hpp
    /usr/include/opencv2/shape/shape.hpp
    /usr/include/opencv2/shape/shape_distance.hpp
    /usr/include/opencv2/shape/shape_transformer.hpp
Generating module 'highgui' from headers:
    /usr/include/opencv2/highgui.hpp
    /usr/include/opencv2/highgui/highgui.hpp
Generating module 'stitching' from headers:
    /usr/include/opencv2/stitching.hpp
    /usr/include/opencv2/stitching/warpers.hpp
Generating module 'img_hash' from headers:
    /usr/include/opencv2/img_hash.hpp
    /usr/include/opencv2/img_hash/average_hash.hpp
    /usr/include/opencv2/img_hash/block_mean_hash.hpp
    /usr/include/opencv2/img_hash/color_moment_hash.hpp
    /usr/include/opencv2/img_hash/img_hash_base.hpp
    /usr/include/opencv2/img_hash/marr_hildreth_hash.hpp
    /usr/include/opencv2/img_hash/phash.hpp
    /usr/include/opencv2/img_hash/radial_variance_hash.hpp
Generating module 'ml' from headers:
    /usr/include/opencv2/ml.hpp
    /usr/include/opencv2/ml/ml.hpp
Generating module 'structured_light' from headers:
    /usr/include/opencv2/structured_light.hpp
    /usr/include/opencv2/structured_light/graycodepattern.hpp
    /usr/include/opencv2/structured_light/sinusoidalpattern.hpp
    /usr/include/opencv2/structured_light/structured_light.hpp
Generating module 'imgcodecs' from headers:
    /usr/include/opencv2/imgcodecs.hpp
    /usr/include/opencv2/imgcodecs/imgcodecs.hpp
Generating module 'phase_unwrapping' from headers:
    /usr/include/opencv2/phase_unwrapping.hpp
    /usr/include/opencv2/phase_unwrapping/histogramphaseunwrapping.hpp
    /usr/include/opencv2/phase_unwrapping/phase_unwrapping.hpp
Generating module 'superres' from headers:
    /usr/include/opencv2/superres.hpp
Generating module 'objdetect' from headers:
    /usr/include/opencv2/objdetect.hpp
    /usr/include/opencv2/objdetect/detection_based_tracker.hpp
    /usr/include/opencv2/objdetect/objdetect.hpp
Generating module 'photo' from headers:
    /usr/include/opencv2/photo.hpp
    /usr/include/opencv2/photo/photo.hpp
Generating module 'plot' from headers:
    /usr/include/opencv2/plot.hpp
Generating module 'text' from headers:
    /usr/include/opencv2/text.hpp
    /usr/include/opencv2/text/erfilter.hpp
    /usr/include/opencv2/text/ocr.hpp
    /usr/include/opencv2/text/textDetector.hpp
Generating module 'saliency' from headers:
    /usr/include/opencv2/saliency.hpp
    /usr/include/opencv2/saliency/saliencyBaseClasses.hpp
    /usr/include/opencv2/saliency/saliencySpecializedClasses.hpp
Generating module 'videoio' from headers:
    /usr/include/opencv2/videoio.hpp
    /usr/include/opencv2/videoio/registry.hpp
    /usr/include/opencv2/videoio/videoio.hpp
Generating module 'video' from headers:
    /usr/include/opencv2/video.hpp
    /usr/include/opencv2/video/background_segm.hpp
    /usr/include/opencv2/video/tracking.hpp
    /usr/include/opencv2/video/video.hpp
Generating module 'core' from headers:
    /usr/include/opencv2/core.hpp
    /usr/include/opencv2/core/affine.hpp
    /usr/include/opencv2/core/base.hpp
    /usr/include/opencv2/core/bindings_utils.hpp
    /usr/include/opencv2/core/bufferpool.hpp
    /usr/include/opencv2/core/check.hpp
    /usr/include/opencv2/core/core.hpp
    /usr/include/opencv2/core/cv_cpu_helper.h
    /usr/include/opencv2/core/cvdef.h
    /usr/include/opencv2/core/directx.hpp
    /usr/include/opencv2/core/hal/interface.h
    /usr/include/opencv2/core/mat.hpp
    /usr/include/opencv2/core/matx.hpp
    /usr/include/opencv2/core/neon_utils.hpp
    /usr/include/opencv2/core/optim.hpp
    /usr/include/opencv2/core/ovx.hpp
    /usr/include/opencv2/core/saturate.hpp
    /usr/include/opencv2/core/softfloat.hpp
    /usr/include/opencv2/core/sse_utils.hpp
    /usr/include/opencv2/core/traits.hpp
    /usr/include/opencv2/core/types.hpp
    /usr/include/opencv2/core/utility.hpp
    /usr/include/opencv2/core/utils/filesystem.hpp
    /usr/include/opencv2/core/utils/logger.defines.hpp
    /usr/include/opencv2/core/utils/logger.hpp
    /usr/include/opencv2/core/va_intel.hpp
    /usr/include/opencv2/core/version.hpp
    /usr/include/opencv2/core/vsx_utils.hpp
    /usr/include/opencv2/core/wimage.hpp
Generating module 'bioinspired' from headers:
    /usr/include/opencv2/bioinspired.hpp
    /usr/include/opencv2/bioinspired/bioinspired.hpp
    /usr/include/opencv2/bioinspired/retina.hpp
    /usr/include/opencv2/bioinspired/retinafasttonemapping.hpp
    /usr/include/opencv2/bioinspired/transientareassegmentationmodule.hpp
Generating module 'ccalib' from headers:
    /usr/include/opencv2/ccalib.hpp
    /usr/include/opencv2/ccalib/multicalib.hpp
    /usr/include/opencv2/ccalib/omnidir.hpp
    /usr/include/opencv2/ccalib/randpattern.hpp
Generating module 'videostab' from headers:
    /usr/include/opencv2/videostab.hpp
    /usr/include/opencv2/videostab/deblurring.hpp
    /usr/include/opencv2/videostab/fast_marching.hpp
    /usr/include/opencv2/videostab/fast_marching_inl.hpp
    /usr/include/opencv2/videostab/frame_source.hpp
    /usr/include/opencv2/videostab/global_motion.hpp
    /usr/include/opencv2/videostab/inpainting.hpp
    /usr/include/opencv2/videostab/log.hpp
    /usr/include/opencv2/videostab/motion_core.hpp
    /usr/include/opencv2/videostab/motion_stabilizing.hpp
    /usr/include/opencv2/videostab/optical_flow.hpp
    /usr/include/opencv2/videostab/outlier_rejection.hpp
    /usr/include/opencv2/videostab/ring_buffer.hpp
    /usr/include/opencv2/videostab/stabilizer.hpp
    /usr/include/opencv2/videostab/wobble_suppression.hpp
Generating module 'calib3d' from headers:
    /usr/include/opencv2/calib3d.hpp
    /usr/include/opencv2/calib3d/calib3d.hpp
Generating module 'viz' from headers:
    /usr/include/opencv2/viz.hpp
    /usr/include/opencv2/viz/types.hpp
    /usr/include/opencv2/viz/viz3d.hpp
    /usr/include/opencv2/viz/vizcore.hpp
    /usr/include/opencv2/viz/widget_accessor.hpp
    /usr/include/opencv2/viz/widgets.hpp

--- stderr
thread '<unnamed>' panicked at 'explicit panic', build.rs:199:13
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

It fails on a bare panic and doesn't provide any useful information about what went wrong.

edit: So, I downloaded the OpenCV 3.4.6 tarball, compiled that with the options that are in the .travis config, and then tried again. It did work this time. However I'd still kind of like to know if there's a problem with Fedora's opencv-devel package or if this can be fixed to work with that.

edit2: It looks like core_objdetect.hpp is part of opencv_contrib

twistedfall commented 5 years ago

Yep, I haven't tried it with contrib yet, so some things are expected to not work, I'll take a look

twistedfall commented 5 years ago

Check v0.12.0, it should now build with contrib fine, some modules are even useful out of the box

dralley commented 5 years ago

Wow, that was fast! It does work now (well, it builds at least, haven't done anything else yet) - thank you!