Skip to content

How to modify link behavior according to enabled features? #667

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

Open
czf0613 opened this issue Apr 16, 2025 · 1 comment
Open

How to modify link behavior according to enabled features? #667

czf0613 opened this issue Apr 16, 2025 · 1 comment

Comments

@czf0613
Copy link

czf0613 commented Apr 16, 2025

I am using OpenCV to perform some basic image processing task.
I only need the imgcodec, imgproc functions, so I set the crate feature like this:

[dependencies]
opencv = { version = "0.94", default-features = false, features = [
    "imgcodecs",
    "imgproc",
    "clang-runtime",
] }

But the linker always link all the libs provided by OpenCV, it makes me really hard to distribute my app.

/opt/homebrew/opt/opencv/lib/libopencv_gapi.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_stitching.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_alphamat.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_aruco.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_bgsegm.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_bioinspired.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_ccalib.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_dnn_objdetect.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_dnn_superres.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_dpm.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_face.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_freetype.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_fuzzy.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_hfs.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_img_hash.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_intensity_transform.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_line_descriptor.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_mcc.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_quality.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_rapid.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_reg.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_rgbd.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_saliency.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_sfm.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_signal.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_stereo.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_structured_light.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_phase_unwrapping.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_superres.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_optflow.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_surface_matching.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_tracking.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_highgui.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_datasets.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_text.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_plot.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_videostab.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_videoio.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_viz.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_wechat_qrcode.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_xfeatures2d.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_shape.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_ml.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_ximgproc.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_video.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_xobjdetect.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_objdetect.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_calib3d.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_imgcodecs.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_features2d.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_dnn.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_flann.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_xphoto.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_photo.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_imgproc.411.dylib (compatibility version 411.0.0, current version 4.11.0)
	/opt/homebrew/opt/opencv/lib/libopencv_core.411.dylib (compatibility version 411.0.0, current version 4.11.0)

I just need libopencv_core, libopencv_imgproc and libopencv_imgcodec. I don't need all of them.

@twistedfall
Copy link
Owner

Check the following section of the readme: https://github.com/twistedfall/opencv-rust?tab=readme-ov-file#environment-variables You're looking to use OPENCV_LINK_LIBS environment variable to override the detected libs to link.

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

2 participants