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

Build Error: error LNK2019: unresolved external symbol cv_GpuMat_Allocator_delete #470

Closed
pyhinox opened this issue Jun 10, 2023 · 9 comments

Comments

@pyhinox
Copy link

pyhinox commented Jun 10, 2023

Hello, when use GpuMat in my project, a build error occurred that "LNK2019: unresolved external symbol cv_GpuMat_Allocator_delete". I can not find any useful info from the internet, can you help me?

Before reporting an issue please first check the
troubleshooting guide. If
the issue you're encountering is not solved thereby please state the following in your bugreport:

  1. Operating system: Windows 11
  2. The way you installed OpenCV: I build opencv from source code with contrib and cuda support through cmake-gui + VS 2022
  3. OpenCV version: 4.7.0
  4. rustc version (rustc --version): rustc 1.70.0 (90c541806 2023-05-31)
  5. Attach the full output of the following command from your project directory:
    RUST_BACKTRACE=full cargo build -vv 

D:/env/Rust/.cargo/bin/cargo.exe build --color=always --message-format=json-diagnostic-rendered-ansi --package xcv --bin xcv
Compiling xcv v0.1.0 (D:\project\xcv)
warning:
......
|
8 | pub fn INTERCEPTION_MOUSE(index: i32) -> i32 { INTERCEPTION_MAX_KEYBOARD + index + 1 }
| ^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: interception_mouse

error: linking with link.exe failed: exit code: 1120
|
= note: "D:\service\Microsoft\VisualStudio\2022\VC\Tools\MSVC\14.36.32532\bin\HostX64\x64\link.exe" "/NOLOGO" "D:\temp\user\rustcgSB1M7\symbols.o" "D:\project\xcv\target\debug\deps\xcv.15q56tcqj60b4eoc.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.168twuv7qda9p2qp.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.1al7bgqtpduzyvld.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.1lpi2yzwrrofr0av.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.1sglszedxgigdx1r.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.1tenyn2jzcpgn4ee.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.1xwqft9qm9uv5lut.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.22o42f8gnrm0j2nw.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.24a17951nt8v8k17.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2a1wyylm850p0yp8.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2b72ve8y0ficw3tf.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2cau7x32jvk3d0bk.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2eiix7jm9h8mm3tv.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2f767gifg0rsmz5x.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2fckap8pf4mi1505.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2l7gnzjtx9wthcb1.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2odonewv8c4o076p.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2s3tiivt9gtig53.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2syq7q79yw3q6imh.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.32gkxfb116pzbzhb.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.3dlrv2fd85am6o06.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.3hi9evcgxqpnbr8e.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.3jzl7ovgckzm1tg1.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.3p4lnxr9i5b605fe.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.3qviespqba0yiy2s.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.3wjj2ulkrsmfh4nk.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.3yv5mj37ctx3qylo.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.3z3gj5ffhyesqwop.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.4f0ybh75ghhej100.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.4j21rjzw9arbhfnf.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.4kyi4iy0fqqww23s.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.4lnbcd2l4i038j8f.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.50xibifcyr6aj4x2.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.53krhxczuyse8xs2.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.586hf7gzvb8u7cni.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.5cusmnokrniyxrar.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.5e0x6hzj1h73g2sd.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.7k7ys46mjywb1ni.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.durvlwec5e1hwx2.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.g1hs7f0k5r0hq5b.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.hz9wumg9h34wg4k.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.l20zqin7au4mjs0.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.lv676vgbzgox6j8.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.o1053wiy62rc7zb.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.o7cag681jtcdy6a.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.ogkc4gnzscaicoc.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.tifc7y2huxpui7t.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.vt7px00sjepxfnf.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.xg6oyikkh25xpyh.rcgu.o" "D:\project\xcv\target\debug\deps\xcv.2wneh2qgyge6e6zl.rcgu.o" "/LIBPATH:D:\project\xcv\target\debug\deps" "/LIBPATH:D:\project\xcv\lib" "/LIBPATH:D:\service\Microsoft\VisualStudio\2022\VC\Tools\MSVC\14.36.32532\atlmfc\lib\x64" "/LIBPATH:D:\project\xcv\target\debug\build\opencv-9c0a232addcb6154\out" "/LIBPATH:D:\source\opencv\build\install\x64\vc17\lib" "/LIBPATH:D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib" "interception.lib" "D:\project\xcv\target\debug\deps\libdxgcap-8eec1290ba08b15a.rlib" "D:\project\xcv\target\debug\deps\libwio-0bb251379df42bc3.rlib" "D:\project\xcv\target\debug\deps\libwinapi-74daf1cb105c85e3.rlib" "D:\project\xcv\target\debug\deps\libyou_can-01e6ba98303db5be.rlib" "D:\project\xcv\target\debug\deps\libopencv-e84c30dd7fd31eed.rlib" "D:\project\xcv\target\debug\deps\liblibc-5de92788d2ed9ecc.rlib" "D:\project\xcv\target\debug\deps\libnum_traits-7778801a2652676b.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd-391022a4250a8b9a.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libpanic_unwind-3069c74fd845ecc2.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_demangle-cae8325b8f11cb55.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd_detect-6ecbb4a24be3ec33.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libhashbrown-7cef55517a70b408.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libminiz_oxide-d1e72b1788c7e8f6.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libadler-65d80753bac4b1a6.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_std_workspace_alloc-932a6231bea08890.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libunwind-04ed514427316340.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcfg_if-9b75e26b1d0a074f.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liblibc-95c2795d82b7b742.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liballoc-1bf02ac2d8cdb80a.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_std_workspace_core-117dfa1fe8688bcf.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcore-9ac5797c0b4842d0.rlib" "D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcompiler_builtins-ad271357e078d260.rlib" "advapi32.lib" "d3d11.lib" "dxgi.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "opengl32.lib" "user32.lib" "winspool.lib" "opencv_world470.lib" "legacy_stdio_definitions.lib" "kernel32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "ntdll.lib" "msvcrt.lib" "legacy_stdio_definitions.lib" "/NXCOMPAT" "/LIBPATH:D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib" "/OUT:D:\project\xcv\target\debug\deps\xcv.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\intrinsic.natvis" "/NATVIS:D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\liballoc.natvis" "/NATVIS:D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libcore.natvis" "/NATVIS:D:\env\Rust\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libstd.natvis"
= note: xcv.lv676vgbzgox6j8.rcgu.o : error LNK2019: 无法解析的外部符号 cv_GpuMat_Allocator_delete,函数 ZN85$LT$opencv..opencv..hub..core..GpuMat_Allocator$u20$as$u20$core..ops..drop..Drop$GT$4drop17hf41daa2065ccedf6E 中引用了该符号
D:\project\xcv\target\debug\deps\xcv.exe : fatal error LNK1120: 1 个无法解析的外部命令

error: aborting due to previous error; 92 warnings emitted

error: could not compile xcv (bin "xcv") due to 2 previous errors; 92 warnings emitted
Process finished with exit code 101

@pyhinox
Copy link
Author

pyhinox commented Jun 11, 2023

I try to add opencv_img_hash470.lib onto environment variable like this: "OPENCV_LINK_LIBS=opencv_world470,opencv_img_hash470" and it work.

@twistedfall
Copy link
Owner

Yes, this is the correct way to solve this problem, Windows lacks a way to automatically detect installed OpenCV library (except for when it's installed from vcpkg) so you need to do a manual setup for it.

@oxidizing-crab
Copy link

oxidizing-crab commented Jun 19, 2023

Hello there! I was about to open an issue on this too and I found this issue.

Differently from this issue, I'm on:

1.Operating system: linux-aarch64 Ubuntu 20.04
1.The way you installed OpenCV: I build opencv from source code with contrib and cuda 11.4 using the make and make install commands
1.OpenCV version: 4.7.0
1.rustc version (rustc --version): rustc 1.70.0 (90c541806 2023-05-31)

and the issue is basically the same, a linker error to the GpuMat allocator destructor, I'll prepare the verbose output, but it might not be necessary.

I've already checked and the opencv_img_hash lib is in the path and as a library to link. I compiled opencv to separate libraries, that's another difference to this issue. If compiling it to the world library could solve the problem, that's a possibility I could try.

One last addition, the crate compiles fine in the version "0.81.*", but when I update it to the version "0.82.*" it doesn't compile anymore. Even with a clean build.

I would also like to seize this comment and ask if there is any priority system to the things that needs fixme or todo, I want to help, if I'm able todo so.

@nvandamme
Copy link

nvandamme commented Jun 25, 2023

Hi,

Same here, on windows, either with a chocolatey build or a vcpkg build, 0.82.* doesn't link with the missing symbol GpuMat_Allocator_delete. Downgrading to 0.81.* fix the linkage problem.

@twistedfall
Copy link
Owner

Thanks for the report, @nvandamme @oxidizing-crab ! I’ll take a look at this regression ASAP

@oxidizing-crab
Copy link

I appreciate your help!! please, let me know if I can be of any help!

@twistedfall
Copy link
Owner

This problem should be fixed in v0.84.2

@oxidizing-crab
Copy link

It was solved, thank you very much!!

Would you mind to losely point what was happening?

When I read the verbose output, it seemed that it wasn't able to find the cuda installation.

@twistedfall
Copy link
Owner

twistedfall commented Aug 1, 2023

It was due to a regression introduced in v0.82.0, while re-working the handling of abstract classes I missed a specific case where they were used (https://docs.rs/opencv/latest/opencv/core/struct.GpuMat.html#method.default_allocator) that regression led to the fact that the code path for deleting GpuMat_Allocator had become live thus leading to the linkage issues (and attempting to free the null pointer (in #478). Regression was introduced in b19ba6fe and fixed in 4e09bc0

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

4 participants