Skip to content

windows using vcpkg: debug builds fail with LNK2005 (symbol already defined) #676

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
rursprung opened this issue May 19, 2025 · 0 comments

Comments

@rursprung
Copy link

this is on windows 11 x64 with OpenCV installed statically via vcpkg and using the latest stable rustc (1.87.0).
i can run cargo build --release successfully, however with cargo build (i.e. debug build) it always fails because it finds the OpenCV symbols twice: once from the debug lib and once from the release lib, e.g.:

  = note: opencv_core4.lib(matrix_expressions.cpp.obj) : error LNK2005: "public: __cdecl cv::MatExpr::MatExpr(class cv::Mat const &)" (??0MatExpr@cv@@QEAA@AEBVMat@1@@Z) already defined in opencv_core4d.lib(opencv_core4d.dll)␍

(there are a ton more of those, see the full output in the gist below)

i'm not sure why it tries to link against the release libs (e.g. opencv_core4.lib) as well as the debug lib (e.g. opencv_core4d.lib) during the debug build and i'm not sure whether this is a problem of opencv-rust or of vcpkg?

this is not specific to one project, i have this with all projects where i try to use opencv-vcpkg. i can e.g. reproduce this with my test project

build output (after cargo clean): https://gist.github.com/rursprung/b1b809520f39341ff7b2e30375db5d2d

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

1 participant