gpt4 book ai didi

visual-studio - LNK2005 将静态 openCV 库与 Visual Studio 和 QT Creator 链接时出错

转载 作者:太空宇宙 更新时间:2023-11-03 20:47:51 24 4
gpt4 key购买 nike

我构建了静态 openCV 2.3 库。我的项目目前使用动态库没有问题,但现在我想使用静态库。我将库添加到我的 .pro 文件中:

LIBS += "C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_calib3d231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_contrib231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_core231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_features2d231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_flann231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_gpu231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_haartraining_engine.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_highgui231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_imgproc231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_legacy231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_ml231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_objdetect231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_ts231.lib" \
"C:\Program Files\openCV_VS_static\opencv\build\lib\Release\opencv_video231.lib"

并包含目录:

INCLUDEPATH += "C:\Program Files\openCV_VS_static\opencv\build\include"
INCLUDEPATH += "C:\Program Files\openCV_VS_static\opencv\build\include\opencv"

当我尝试构建时出现以下错误:

LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRT.lib(MSVCR100.dll)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRT.lib(MSVCR100.dll)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

感谢任何帮助或建议。

最佳答案

在 CMake 上,在构建 openCV 静态库时,除了取消选中 BUILD_SHARED_LIBS 之外,我还取消选中 BUILD_WITH_STATIC_CRT,这解决了这个特定问题

关于visual-studio - LNK2005 将静态 openCV 库与 Visual Studio 和 QT Creator 链接时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9697935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com