Skip to content
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

Unable to statically link OpenCV without OpenCL support on windows. #532

Closed
CeNiEi opened this issue Dec 30, 2023 · 4 comments
Closed

Unable to statically link OpenCV without OpenCL support on windows. #532

CeNiEi opened this issue Dec 30, 2023 · 4 comments

Comments

@CeNiEi
Copy link

CeNiEi commented Dec 30, 2023

i have been experimenting with the crate, and found that if i disable OpenCL when compiling the static lib files of OpenCV, i am unable to link it correctly to my app.
I get the following link error:

          libopencv-3b3b70e538e42495.rlib(8cdb024d75981777-core.o) : error LNK2019: unresolved external symbol "public: bool __cdecl cv::ocl::Kernel::run_(int,unsigned __int64 * const,unsigned __int64 * const,bool,class cv::ocl::Queue const &)" (?run_@Kernel@ocl@cv@@QEAA_NHQEA_K0_NAEBVQueue@23@@Z) referenced in function cv_ocl_Kernel_run__int_size_tX_size_tX_bool_const_QueueR
          libopencv-3b3b70e538e42495.rlib(8cdb024d75981777-core.o) : error LNK2019: unresolved external symbol "public: int __cdecl cv::ocl::PlatformInfo::versionMajor(void)const " (?versionMajor@PlatformInfo@ocl@cv@@QEBAHXZ) referenced in function cv_ocl_PlatformInfo_versionMajor_const
          libopencv-3b3b70e538e42495.rlib(8cdb024d75981777-core.o) : error LNK2019: unresolved external symbol "public: int __cdecl cv::ocl::PlatformInfo::versionMinor(void)const " (?versionMinor@PlatformInfo@ocl@cv@@QEBAHXZ) referenced in function cv_ocl_PlatformInfo_versionMinor_const
          libopencv-3b3b70e538e42495.rlib(8cdb024d75981777-core.o) : error LNK2019: unresolved external symbol "char const * __cdecl cv::ocl::convertTypeStr(int,int,int,char *,unsigned __int64)" (?convertTypeStr@ocl@cv@@YAPEBDHHHPEAD_K@Z) referenced in function cv_ocl_convertTypeStr_int_int_int_charX_size_t
          C:\Users\ryuji\unicorns\cvwin\target\debug\deps\cvwin.exe : fatal error LNK1120: 4 unresolved externals

I am not sure why OpenCL symbols are being generated in the first place, since i set the WITH_OPENCL flag to OFF, when compiling OpenCV? Any clues what might be happening here?

I am not sure, if the output of cargo b -vv would be helpful here, but i am more than happy to provide it, if need be.

@CeNiEi CeNiEi changed the title Unable to statically compile opencv without opencl support on windows. Unable to statically compile OpenCV without OpenCL support on windows. Dec 30, 2023
@CeNiEi CeNiEi changed the title Unable to statically compile OpenCV without OpenCL support on windows. Unable to statically link OpenCV without OpenCL support on windows. Dec 30, 2023
@twistedfall
Copy link
Owner

Do you still have this issue? If so cargo build -vv is always useful to provide the insight into what's happening during binding generation. Please also be sure to use the latest crate version (0.90.0 at the moment of writing)

@PaulWagener
Copy link

I also just ran into this issue with the latest version (0.94.1)
For reference I was using the following vcpkg configuration:

[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "c7961da7380ecdb92242c9dbc8ee1bca2105e335"
dependencies = ["llvm", "opencv4[contrib,nonfree]", "proj", "gdal"]

[package.metadata.vcpkg.target]
x86_64-pc-windows-msvc = { triplet = "x64-windows-static-release" }

Changing the OpenCV dependency to opencv4[contrib,nonfree,opencl] solved this issue for me. Though it would be nice if this was optional.

@twistedfall
Copy link
Owner

Thanks for the update, is there any chance you can test the alpha branch with vcpkg built without OpenCL and see if it works for you now?

@twistedfall
Copy link
Owner

This should now be fixed in 0.94.2

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

3 participants