簡體   English   中英

LNK2038,MSVS2017 MAGMA的原因列表

[英]List of causes for LNK2038, MSVS2017 MAGMA

我的目標是通過編譯(無濟於事)LNK2038“檢測到'_ITERATOR_DEBUG_LEVEL'的不匹配:值'0'與值'2'不匹配”的原因列表,其他人可能會循序漸進地調試他們自己的情況,我的情況將解決

我的情況:

要求:

  • Windows 10
  • CMake的
  • MSVS 2017
  • 英特爾Paralax Studio XE
  • 卡達

復制:

  1. 下載MAGMA
  2. 運行CMake GUI

    • 手動設置GPU_TARGET=Pascal (我的卡:GeForce GTX 1070計算能力:6.1)
    • 手動設置MKLROOT=D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl (如README-Windows中所述)
    • LAPACK_LIBRARIES:使用https://software.intel.com/zh-CN/articles/intel-mkl-link-line-advisor確定

      • 我的選擇
      • D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_intel_lp64.lib;D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_intel_thread.lib;D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_core.lib;D:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2019.0.117/windows/compiler/lib/intel64_win/libiomp5md.lib
  3. 從生成的VS解決方案中,以Debug模式編譯magmamagma_sparse項目(無需編譯600多個測試項目)

  4. 在單獨的文件夾中放入示例代碼CMakeLists.txt

     add_executable(magma-test example_sparse.cpp) find_package( CUDA ) # just to set CUDA_INCLUDE_DIRS target_include_directories(magma-test PUBLIC D:/Work/Magma/magma-2.4.0/include D:/Work/Magma/magma-2.4.0/sparse/include ${CUDA_INCLUDE_DIRS}) target_link_libraries(magma-test debug D:/Work/Magma/magma-2.4.0/build/lib/Debug/magma.lib debug D:/Work/Magma/magma-2.4.0/build/lib/Debug/magma_sparse.lib) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") 
  5. 運行CMake(配置,生成)

  6. 打開VS解決方案,並在Debug模式下進行編譯

有問題的結果:

1>magma_sparse.lib(magma_sparse_generated_djacobisetup.cu.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in magma.lib(interface.obj)

1>magma_sparse.lib(magma_sparse_generated_djacobisetup.cu.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in magma.lib(interface.obj)

----------

LNK2038檢查事項:

  1. 所有依賴項(* .lib文件)都使用相同的“ Debug / Release”標志進行編譯
    • 右鍵單擊項目->屬性->鏈接器->輸入->其他依賴項,仔細檢查實際使用的依賴項
    • 轉到每個依賴項項目以及您的項目,然后通過右鍵單擊Project-> Properties-> C / C ++-> Code Generation-> Runtime Library來檢查構建標志。

一個“解決”以上錯誤,編譯並運行的CMakeLists.txt是:

add_executable(magma-test example_sparse.cpp)

find_package( CUDA ) 
set( MKLROOT "D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl" )
set( LAPACK_LIBRARIES 
   "D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_intel_lp64.lib"
   "D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_intel_thread.lib"
   "D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_core.lib"
   "D:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2019.0.117/windows/compiler/lib/intel64_win/libiomp5md.lib")

target_include_directories(magma-test PUBLIC 
   "D:/Work/Magma/magma-2.4.0/include" 
   "D:/Work/Magma/magma-2.4.0/sparse/include" 
   ${CUDA_INCLUDE_DIRS}
   ${MKLROOT}/include)
target_link_libraries(magma-test 
   ${CUDA_CUDART_LIBRARY}
   ${CUDA_CUBLAS_LIBRARIES}
   ${CUDA_cusparse_LIBRARY}
   ${LAPACK_LIBRARIES}
   debug D:/Work/Magma/magma-2.4.0/build/lib/Debug/magma.lib 
   debug D:/Work/Magma/magma-2.4.0/build/lib/Debug/magma_sparse.lib
   optimized D:/Work/Magma/magma-2.4.0/build/lib/Release/magma.lib 
   optimized D:/Work/Magma/magma-2.4.0/build/lib/Release/magma_sparse.lib)

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")

似乎還必須為使用MAGMA庫的代碼提供MAGMA在編譯時使用的CUDA和MKL庫

編輯:等等,不。 它是在Release中編譯和運行的,但不是在Debug中運行的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM