Skip to content

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

Description

@rursprung

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions