-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
statically compiling opencv #364
Comments
Probably static linking is a solution, I haven’t tested this option, but there were a couple of successful mentions. And working with mobile devices is also something I haven’t really considered so far. So if you manage to get something working I would really like to hear about it! |
Hi there, I read on the opencv website that the library was adjusted for ios and android. So I think compiling them for the platforms should work? I am new to rust bindings to C and C++. I'm trying to dig through the build script. How does one go about statically linking opencv? Thanks @twistedfall |
Would it be possible to introduce a feature flag on the crate to decide between static and dynamic linking? |
In theory, yes, but I can't say that I tried that myself
In theory it's just about the linker flags. If you manage to get something working I would really appreciate the PR. Having a feature flag for switching between dynamic and static linking is a good idea! |
I've forked the repo and have edited the RUSTFLAGS. I've been trying to test it out in a local cargo project but it seems to return errors saying that all the probes failed to find opencv. It is returning errors that environment and vcpkg cannot probe it properly - how can I fix this in the build script? |
It seems to work when I build my program for my host but it seems to break when cross-compiling. It says environment and vcpkg cannot probe opencv. |
Are there any examples of how to do the static linking? |
I read that changing the LDFLAGS can switch between dynamic and static. But it seems to not include opencv in the dylib. |
I'm going to close this issue in favor of the already existing one about static compilation: #104 |
Hello, In my project I only use features: face and imgproc: Here are the compiling steps:
|
That's really helpful, thank you! I will try to include this step into the CI and update the readme |
Maybe you should also mention that it is a bit tricky to get the right ordering from libs in With libz I was not sure which one to choice, the static or the dynamic one. The rust program will link against the dynamic library, but openCV I guess will link to the static one. |
I've added the static build to CI and updated the readme: https://github.com/twistedfall/opencv-rust#static-build |
Question: I'm trying to statically compile opencv, as well (on Ubuntu focal fossa). I'm not sure which script I'm supposed to run, install-focal.sh or script.sh. Why do you have a linux install script in both; what does one do that the other doesn't? And if I do run install-focal.sh, how do I run it? Do I run |
For installation of the static OpenCV itself on Ubuntu use the |
For anyone looking at this in the future, I have a github actions workflow file that statically links OpenCV into my binary for Windows, macOS, and Linux There are also comments in workflow file to help understand the differences between platforms |
Hi there,
I saw on your README that opencv has to be installed on the device for it to run. I am writing an app in flutter (aimed at android, ios, windows, linux, macos) which has bits of rust using opencv. How can I package opencv with the app? This is mostly for the mobile versions which may not have it installed.
Thanks
The text was updated successfully, but these errors were encountered: