Libcpmt.lib:为 'RuntimeLibrary' 检测到错误 LNK2038 不匹配:值 'MT_StaticRelease' 与值 'MD_DynamicRelease' 不匹配
Libcpmt.lib: Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'
在编译当前项目时,我遇到了一堆(大约 80 个)链接器错误,我不知道如何进一步调试。
我用的是Visual Studio 2019,是在Windows 10.
上编译的C++项目
其中很多来自名为 libcpmt.lib 的图书馆。
有两种与库相关的错误:
首先它声称在msvcprt.lib(MSVCP140.dll)中已经定义了一些函数(这很奇怪,因为我使用的是Visual Studio 2019 v142)
Error LNK2005 "protected: __cdecl std::locale::facet::facet(unsigned __int64)" (??0facet@locale@std@@IEAA@_K@Z) already defined in msvcprt.lib(MSVCP140.dll) DataConverter path_to_project\libcpmt.lib(locale0.obj)
其次,它声称 libcpmt.lib 是静态编译的,而我的项目使用动态链接库。
Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in annotation.obj DataConverter path_to_project\libcpmt.lib(xstol.obj) 1
同样的错误也出现在名为mpirxx.lib
的库中
Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in annotation.obj DataConverter path_to_project\mpirxx.lib(osmpf.obj) 1
和
Error LNK2005 "public: void __cdecl std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ) already defined in mpirxx.lib(osmpf.obj) DataConverter path_to_project\msvcprt.lib(MSVCP140.dll) 1
根据我在互联网上发现的关于该库的少量信息,当您的 C++->代码生成->运行时库设置为 MT,但我的设置设置为 MD 时,它似乎包含在内。
我在我的项目中包含了很多外部库:
flann.lib
flann_cpp.lib
Qt5Widgets.lib
qtmain.lib
Qt5Gui.lib
Qt5Core.lib
libboost_atomic-vc142-mt-x64-1_74.lib
libboost_chrono-vc142-mt-x64-1_74.lib
libboost_container-vc142-mt-x64-1_74.lib
libboost_context-vc142-mt-x64-1_74.lib
libboost_contract-vc142-mt-x64-1_74.lib
libboost_coroutine-vc142-mt-x64-1_74.lib
libboost_date_time-vc142-mt-x64-1_74.lib
libboost_exception-vc142-mt-x64-1_74.lib
libboost_fiber-vc142-mt-x64-1_74.lib
libboost_graph-vc142-mt-x64-1_74.lib
libboost_iostreams-vc142-mt-x64-1_74.lib
libboost_locale-vc142-mt-x64-1_74.lib
libboost_log_setup-vc142-mt-x64-1_74.lib
libboost_log-vc142-mt-x64-1_74.lib
libboost_math_c99f-vc142-mt-x64-1_74.lib
libboost_math_c99l-vc142-mt-x64-1_74.lib
libboost_math_c99-vc142-mt-x64-1_74.lib
libboost_math_tr1f-vc142-mt-x64-1_74.lib
libboost_math_tr1l-vc142-mt-x64-1_74.lib
libboost_math_tr1-vc142-mt-x64-1_74.lib
libboost_nowide-vc142-mt-x64-1_74.lib
libboost_numpy37-vc142-mt-x64-1_74.lib
libboost_prg_exec_monitor-vc142-mt-x64-1_74.lib
libboost_program_options-vc142-mt-x64-1_74.lib
libboost_python37-vc142-mt-x64-1_74.lib
libboost_random-vc142-mt-x64-1_74.lib
libboost_regex-vc142-mt-x64-1_74.lib
libboost_serialization-vc142-mt-x64-1_74.lib
libboost_stacktrace_noop-vc142-mt-x64-1_74.lib
libboost_stacktrace_windbg_cached-vc142-mt-x64-1_74.lib
libboost_stacktrace_windbg-vc142-mt-x64-1_74.lib
libboost_system-vc142-mt-x64-1_74.lib
libboost_test_exec_monitor-vc142-mt-x64-1_74.lib
libboost_thread-vc142-mt-x64-1_74.lib
libboost_timer-vc142-mt-x64-1_74.lib
libboost_type_erasure-vc142-mt-x64-1_74.lib
libboost_unit_test_framework-vc142-mt-x64-1_74.lib
libboost_wave-vc142-mt-x64-1_74.lib
libboost_wserialization-vc142-mt-x64-1_74.lib
bz2.lib
libpng16.lib
lz4.lib
lzma.lib
mpfr.lib
mpir.lib
mpirxx.lib
qhullcpp.lib
xxhash.lib
zlib.lib
zstd.lib
gmp.lib
glew32.lib
glew32s.lib
opencv_world440.lib
vtkChartsCore-9.0.lib
vtkCommonColor-9.0.lib
vtkCommonComputationalGeometry-9.0.lib
vtkCommonCore-9.0.lib
vtkCommonDataModel-9.0.lib
vtkCommonExecutionModel-9.0.lib
vtkCommonMath-9.0.lib
vtkCommonMisc-9.0.lib
vtkCommonSystem-9.0.lib
vtkCommonTransforms-9.0.lib
vtkDICOMParser-9.0.lib
vtkDomainsChemistry-9.0.lib
vtkdoubleconversion-9.0.lib
vtkexodusII-9.0.lib
vtkexpat-9.0.lib
vtkFiltersAMR-9.0.lib
vtkFiltersCore-9.0.lib
vtkFiltersExtraction-9.0.lib
vtkFiltersFlowPaths-9.0.lib
vtkFiltersGeneral-9.0.lib
vtkFiltersGeneric-9.0.lib
vtkFiltersGeometry-9.0.lib
vtkFiltersHybrid-9.0.lib
vtkFiltersHyperTree-9.0.lib
vtkFiltersImaging-9.0.lib
vtkFiltersModeling-9.0.lib
vtkFiltersParallel-9.0.lib
vtkFiltersParallelImaging-9.0.lib
vtkFiltersPoints-9.0.lib
vtkFiltersProgrammable-9.0.lib
vtkFiltersSelection-9.0.lib
vtkFiltersSMP-9.0.lib
vtkFiltersSources-9.0.lib
vtkFiltersStatistics-9.0.lib
vtkFiltersTexture-9.0.lib
vtkFiltersTopology-9.0.lib
vtkFiltersVerdict-9.0.lib
vtkfreetype-9.0.lib
vtkGeovisCore-9.0.lib
vtkgl2ps-9.0.lib
vtkglew-9.0.lib
vtkhdf5-9.0.lib
vtkhdf5_hl-9.0.lib
vtkImagingColor-9.0.lib
vtkImagingCore-9.0.lib
vtkImagingFourier-9.0.lib
vtkImagingGeneral-9.0.lib
vtkImagingHybrid-9.0.lib
vtkImagingMath-9.0.lib
vtkImagingMorphological-9.0.lib
vtkImagingSources-9.0.lib
vtkImagingStatistics-9.0.lib
vtkImagingStencil-9.0.lib
vtkInfovisCore-9.0.lib
vtkInfovisLayout-9.0.lib
vtkInteractionImage-9.0.lib
vtkInteractionStyle-9.0.lib
vtkInteractionWidgets-9.0.lib
vtkIOAMR-9.0.lib
vtkIOAsynchronous-9.0.lib
vtkIOCityGML-9.0.lib
vtkIOCore-9.0.lib
vtkIOEnSight-9.0.lib
vtkIOExodus-9.0.lib
vtkIOExport-9.0.lib
vtkIOExportGL2PS-9.0.lib
vtkIOExportPDF-9.0.lib
vtkIOGeometry-9.0.lib
vtkIOImage-9.0.lib
vtkIOImport-9.0.lib
vtkIOInfovis-9.0.lib
vtkIOLegacy-9.0.lib
vtkIOLSDyna-9.0.lib
vtkIOMINC-9.0.lib
vtkIOMotionFX-9.0.lib
vtkIOMovie-9.0.lib
vtkIONetCDF-9.0.lib
vtkIOOggTheora-9.0.lib
vtkIOParallel-9.0.lib
vtkIOParallelXML-9.0.lib
vtkIOPLY-9.0.lib
vtkIOSegY-9.0.lib
vtkIOSQL-9.0.lib
vtkIOTecplotTable-9.0.lib
vtkIOVeraOut-9.0.lib
vtkIOVideo-9.0.lib
vtkIOXML-9.0.lib
vtkIOXMLParser-9.0.lib
vtkjpeg-9.0.lib
vtkjsoncpp-9.0.lib
vtklibharu-9.0.lib
vtklibproj-9.0.lib
vtklibxml2-9.0.lib
vtkloguru-9.0.lib
vtklz4-9.0.lib
vtklzma-9.0.lib
vtkmetaio-9.0.lib
vtknetcdf-9.0.lib
vtkogg-9.0.lib
vtkParallelCore-9.0.lib
vtkParallelDIY-9.0.lib
vtkpng-9.0.lib
vtkpugixml-9.0.lib
vtkRenderingAnnotation-9.0.lib
vtkRenderingContext2D-9.0.lib
vtkRenderingCore-9.0.lib
vtkRenderingFreeType-9.0.lib
vtkRenderingGL2PSOpenGL2-9.0.lib
vtkRenderingImage-9.0.lib
vtkRenderingLabel-9.0.lib
vtkRenderingLOD-9.0.lib
vtkRenderingOpenGL2-9.0.lib
vtkRenderingSceneGraph-9.0.lib
vtkRenderingUI-9.0.lib
vtkRenderingVolume-9.0.lib
vtkRenderingVolumeOpenGL2-9.0.lib
vtkRenderingVtkJS-9.0.lib
vtksqlite-9.0.lib
vtksys-9.0.lib
vtkTestingRendering-9.0.lib
vtktheora-9.0.lib
vtktiff-9.0.lib
vtkverdict-9.0.lib
vtkViewsContext2D-9.0.lib
vtkViewsCore-9.0.lib
vtkViewsInfovis-9.0.lib
vtkWrappingTools-9.0.lib
vtkzlib-9.0.lib
pcl_common.lib
pcl_features.lib
pcl_filters.lib
pcl_io.lib
pcl_io_ply.lib
pcl_kdtree.lib
pcl_keypoints.lib
pcl_ml.lib
pcl_octree.lib
pcl_recognition.lib
pcl_registration.lib
pcl_search.lib
pcl_segmentation.lib
pcl_sample_consensus.lib
pcl_stereo.lib
pcl_surface.lib
pcl_tracking.lib
有人知道如何进一步调试或修复这些问题吗?
PS:我目前有另一个可能无关的错误,但为了完整起见,我想将其包括在内。链接器找不到 loadPolygonFilePLY 的库。可能我只是缺少一个额外的 pcl 库。如果有人碰巧知道它的名字,请评论:
Error LNK2001 unresolved external symbol "int __cdecl pcl::io::loadPolygonFilePLY(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct pcl::PolygonMesh &)" (?loadPolygonFilePLY@io@pcl@@YAHAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAUPolygonMesh@2@@Z)
万一有人遇到类似的问题。这些是我包含的库中使用静态链接的库 (mpirxx.lib)。调试此问题的一个好方法是将 /VERBOSE:LIB 放入您的链接器选项中。然后构建并转到您的输出 windows,您可以在其中看到哪个库是第一个触发此错误链的库。
感谢 Alan Birtles 的帮助。
在编译当前项目时,我遇到了一堆(大约 80 个)链接器错误,我不知道如何进一步调试。
我用的是Visual Studio 2019,是在Windows 10.
上编译的C++项目其中很多来自名为 libcpmt.lib 的图书馆。 有两种与库相关的错误:
首先它声称在msvcprt.lib(MSVCP140.dll)中已经定义了一些函数(这很奇怪,因为我使用的是Visual Studio 2019 v142)
Error LNK2005 "protected: __cdecl std::locale::facet::facet(unsigned __int64)" (??0facet@locale@std@@IEAA@_K@Z) already defined in msvcprt.lib(MSVCP140.dll) DataConverter path_to_project\libcpmt.lib(locale0.obj)
其次,它声称 libcpmt.lib 是静态编译的,而我的项目使用动态链接库。
Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in annotation.obj DataConverter path_to_project\libcpmt.lib(xstol.obj) 1
同样的错误也出现在名为mpirxx.lib
的库中Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in annotation.obj DataConverter path_to_project\mpirxx.lib(osmpf.obj) 1
和
Error LNK2005 "public: void __cdecl std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ) already defined in mpirxx.lib(osmpf.obj) DataConverter path_to_project\msvcprt.lib(MSVCP140.dll) 1
根据我在互联网上发现的关于该库的少量信息,当您的 C++->代码生成->运行时库设置为 MT,但我的设置设置为 MD 时,它似乎包含在内。
我在我的项目中包含了很多外部库:
flann.lib
flann_cpp.lib
Qt5Widgets.lib
qtmain.lib
Qt5Gui.lib
Qt5Core.lib
libboost_atomic-vc142-mt-x64-1_74.lib
libboost_chrono-vc142-mt-x64-1_74.lib
libboost_container-vc142-mt-x64-1_74.lib
libboost_context-vc142-mt-x64-1_74.lib
libboost_contract-vc142-mt-x64-1_74.lib
libboost_coroutine-vc142-mt-x64-1_74.lib
libboost_date_time-vc142-mt-x64-1_74.lib
libboost_exception-vc142-mt-x64-1_74.lib
libboost_fiber-vc142-mt-x64-1_74.lib
libboost_graph-vc142-mt-x64-1_74.lib
libboost_iostreams-vc142-mt-x64-1_74.lib
libboost_locale-vc142-mt-x64-1_74.lib
libboost_log_setup-vc142-mt-x64-1_74.lib
libboost_log-vc142-mt-x64-1_74.lib
libboost_math_c99f-vc142-mt-x64-1_74.lib
libboost_math_c99l-vc142-mt-x64-1_74.lib
libboost_math_c99-vc142-mt-x64-1_74.lib
libboost_math_tr1f-vc142-mt-x64-1_74.lib
libboost_math_tr1l-vc142-mt-x64-1_74.lib
libboost_math_tr1-vc142-mt-x64-1_74.lib
libboost_nowide-vc142-mt-x64-1_74.lib
libboost_numpy37-vc142-mt-x64-1_74.lib
libboost_prg_exec_monitor-vc142-mt-x64-1_74.lib
libboost_program_options-vc142-mt-x64-1_74.lib
libboost_python37-vc142-mt-x64-1_74.lib
libboost_random-vc142-mt-x64-1_74.lib
libboost_regex-vc142-mt-x64-1_74.lib
libboost_serialization-vc142-mt-x64-1_74.lib
libboost_stacktrace_noop-vc142-mt-x64-1_74.lib
libboost_stacktrace_windbg_cached-vc142-mt-x64-1_74.lib
libboost_stacktrace_windbg-vc142-mt-x64-1_74.lib
libboost_system-vc142-mt-x64-1_74.lib
libboost_test_exec_monitor-vc142-mt-x64-1_74.lib
libboost_thread-vc142-mt-x64-1_74.lib
libboost_timer-vc142-mt-x64-1_74.lib
libboost_type_erasure-vc142-mt-x64-1_74.lib
libboost_unit_test_framework-vc142-mt-x64-1_74.lib
libboost_wave-vc142-mt-x64-1_74.lib
libboost_wserialization-vc142-mt-x64-1_74.lib
bz2.lib
libpng16.lib
lz4.lib
lzma.lib
mpfr.lib
mpir.lib
mpirxx.lib
qhullcpp.lib
xxhash.lib
zlib.lib
zstd.lib
gmp.lib
glew32.lib
glew32s.lib
opencv_world440.lib
vtkChartsCore-9.0.lib
vtkCommonColor-9.0.lib
vtkCommonComputationalGeometry-9.0.lib
vtkCommonCore-9.0.lib
vtkCommonDataModel-9.0.lib
vtkCommonExecutionModel-9.0.lib
vtkCommonMath-9.0.lib
vtkCommonMisc-9.0.lib
vtkCommonSystem-9.0.lib
vtkCommonTransforms-9.0.lib
vtkDICOMParser-9.0.lib
vtkDomainsChemistry-9.0.lib
vtkdoubleconversion-9.0.lib
vtkexodusII-9.0.lib
vtkexpat-9.0.lib
vtkFiltersAMR-9.0.lib
vtkFiltersCore-9.0.lib
vtkFiltersExtraction-9.0.lib
vtkFiltersFlowPaths-9.0.lib
vtkFiltersGeneral-9.0.lib
vtkFiltersGeneric-9.0.lib
vtkFiltersGeometry-9.0.lib
vtkFiltersHybrid-9.0.lib
vtkFiltersHyperTree-9.0.lib
vtkFiltersImaging-9.0.lib
vtkFiltersModeling-9.0.lib
vtkFiltersParallel-9.0.lib
vtkFiltersParallelImaging-9.0.lib
vtkFiltersPoints-9.0.lib
vtkFiltersProgrammable-9.0.lib
vtkFiltersSelection-9.0.lib
vtkFiltersSMP-9.0.lib
vtkFiltersSources-9.0.lib
vtkFiltersStatistics-9.0.lib
vtkFiltersTexture-9.0.lib
vtkFiltersTopology-9.0.lib
vtkFiltersVerdict-9.0.lib
vtkfreetype-9.0.lib
vtkGeovisCore-9.0.lib
vtkgl2ps-9.0.lib
vtkglew-9.0.lib
vtkhdf5-9.0.lib
vtkhdf5_hl-9.0.lib
vtkImagingColor-9.0.lib
vtkImagingCore-9.0.lib
vtkImagingFourier-9.0.lib
vtkImagingGeneral-9.0.lib
vtkImagingHybrid-9.0.lib
vtkImagingMath-9.0.lib
vtkImagingMorphological-9.0.lib
vtkImagingSources-9.0.lib
vtkImagingStatistics-9.0.lib
vtkImagingStencil-9.0.lib
vtkInfovisCore-9.0.lib
vtkInfovisLayout-9.0.lib
vtkInteractionImage-9.0.lib
vtkInteractionStyle-9.0.lib
vtkInteractionWidgets-9.0.lib
vtkIOAMR-9.0.lib
vtkIOAsynchronous-9.0.lib
vtkIOCityGML-9.0.lib
vtkIOCore-9.0.lib
vtkIOEnSight-9.0.lib
vtkIOExodus-9.0.lib
vtkIOExport-9.0.lib
vtkIOExportGL2PS-9.0.lib
vtkIOExportPDF-9.0.lib
vtkIOGeometry-9.0.lib
vtkIOImage-9.0.lib
vtkIOImport-9.0.lib
vtkIOInfovis-9.0.lib
vtkIOLegacy-9.0.lib
vtkIOLSDyna-9.0.lib
vtkIOMINC-9.0.lib
vtkIOMotionFX-9.0.lib
vtkIOMovie-9.0.lib
vtkIONetCDF-9.0.lib
vtkIOOggTheora-9.0.lib
vtkIOParallel-9.0.lib
vtkIOParallelXML-9.0.lib
vtkIOPLY-9.0.lib
vtkIOSegY-9.0.lib
vtkIOSQL-9.0.lib
vtkIOTecplotTable-9.0.lib
vtkIOVeraOut-9.0.lib
vtkIOVideo-9.0.lib
vtkIOXML-9.0.lib
vtkIOXMLParser-9.0.lib
vtkjpeg-9.0.lib
vtkjsoncpp-9.0.lib
vtklibharu-9.0.lib
vtklibproj-9.0.lib
vtklibxml2-9.0.lib
vtkloguru-9.0.lib
vtklz4-9.0.lib
vtklzma-9.0.lib
vtkmetaio-9.0.lib
vtknetcdf-9.0.lib
vtkogg-9.0.lib
vtkParallelCore-9.0.lib
vtkParallelDIY-9.0.lib
vtkpng-9.0.lib
vtkpugixml-9.0.lib
vtkRenderingAnnotation-9.0.lib
vtkRenderingContext2D-9.0.lib
vtkRenderingCore-9.0.lib
vtkRenderingFreeType-9.0.lib
vtkRenderingGL2PSOpenGL2-9.0.lib
vtkRenderingImage-9.0.lib
vtkRenderingLabel-9.0.lib
vtkRenderingLOD-9.0.lib
vtkRenderingOpenGL2-9.0.lib
vtkRenderingSceneGraph-9.0.lib
vtkRenderingUI-9.0.lib
vtkRenderingVolume-9.0.lib
vtkRenderingVolumeOpenGL2-9.0.lib
vtkRenderingVtkJS-9.0.lib
vtksqlite-9.0.lib
vtksys-9.0.lib
vtkTestingRendering-9.0.lib
vtktheora-9.0.lib
vtktiff-9.0.lib
vtkverdict-9.0.lib
vtkViewsContext2D-9.0.lib
vtkViewsCore-9.0.lib
vtkViewsInfovis-9.0.lib
vtkWrappingTools-9.0.lib
vtkzlib-9.0.lib
pcl_common.lib
pcl_features.lib
pcl_filters.lib
pcl_io.lib
pcl_io_ply.lib
pcl_kdtree.lib
pcl_keypoints.lib
pcl_ml.lib
pcl_octree.lib
pcl_recognition.lib
pcl_registration.lib
pcl_search.lib
pcl_segmentation.lib
pcl_sample_consensus.lib
pcl_stereo.lib
pcl_surface.lib
pcl_tracking.lib
有人知道如何进一步调试或修复这些问题吗?
PS:我目前有另一个可能无关的错误,但为了完整起见,我想将其包括在内。链接器找不到 loadPolygonFilePLY 的库。可能我只是缺少一个额外的 pcl 库。如果有人碰巧知道它的名字,请评论:
Error LNK2001 unresolved external symbol "int __cdecl pcl::io::loadPolygonFilePLY(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct pcl::PolygonMesh &)" (?loadPolygonFilePLY@io@pcl@@YAHAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAUPolygonMesh@2@@Z)
万一有人遇到类似的问题。这些是我包含的库中使用静态链接的库 (mpirxx.lib)。调试此问题的一个好方法是将 /VERBOSE:LIB 放入您的链接器选项中。然后构建并转到您的输出 windows,您可以在其中看到哪个库是第一个触发此错误链的库。
感谢 Alan Birtles 的帮助。