Skip to content

Commit 9a113bd

Browse files
committed
fix(compat.opencv): static CRT (/MT) on Windows to match mcpp consumer
First Windows source build was a near-complete success: clang-cl autodetected MSVC, cmake configured, all of core+imgproc+imgcodecs compiled, install laid the normalised layout (opencv_core.lib etc). Only the consumer link failed LNK2038: OpenCV built /MD (dynamic CRT) but mcpp compiles its objects /MT (roundtrip.o = MT_StaticRelease). Flip BUILD_WITH_STATIC_CRT to ON (/MT, also OpenCV's Windows default) so the RuntimeLibrary matches.
1 parent a29d094 commit 9a113bd

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎pkgs/c/compat.opencv.lua‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,17 @@ local function _install_impl()
388388
-- the default x64/vc17 binaries prefix and the version suffix on lib names
389389
-- (opencv_core.lib, not opencv_core4130.lib), and put static libs under lib/
390390
-- + 3rdparty under lib/opencv4/3rdparty + headers under include/opencv4.
391-
-- BUILD_WITH_STATIC_CRT=OFF builds against the DYNAMIC CRT (/MD) to match
392-
-- mcpp's clang-cl consumer; OpenCV defaults to static CRT (/MT) on Windows,
393-
-- which would clash at link. Expands to nothing off Windows.
391+
-- BUILD_WITH_STATIC_CRT=ON builds against the STATIC CRT (/MT) — mcpp's
392+
-- clang-cl consumer compiles its objects /MT (roundtrip.o = MT_StaticRelease),
393+
-- so OpenCV must match or the link fails LNK2038 (MD vs MT RuntimeLibrary
394+
-- mismatch). /MT is also OpenCV's Windows default. Expands to nothing off
395+
-- Windows.
394396
isWin and ("-DOPENCV_INSTALL_BINARIES_PREFIX= "
395397
.. "-DOPENCV_LIB_INSTALL_PATH=lib "
396398
.. "-DOPENCV_3P_LIB_INSTALL_PATH=lib/opencv4/3rdparty "
397399
.. "-DOPENCV_INCLUDE_INSTALL_PATH=include/opencv4 "
398400
.. "-DOPENCV_DLLVERSION= "
399-
.. "-DBUILD_WITH_STATIC_CRT=OFF") or "",
401+
.. "-DBUILD_WITH_STATIC_CRT=ON") or "",
400402
}, " ")
401403

402404
if isWin then

0 commit comments

Comments
 (0)