依赖于msvcr120d.dll Visual Studio 2015(英特尔TBB)

时间:2015-08-21 03:33:07

标签: c++ visual-c++ visual-studio-2015 tbb

为了让英特尔TBB(线程构建模块)与Visual Studio 2015一起使用,我尝试了以下方法(因为默认情况下,构建的二进制文件仅适用于vs2013)。

使用Visual Studio 2015编译英特尔TBB -

  1. Here下载英特尔TBB的源代码。
  2. 提取它,
  3. 使用路径makefile.sln
  4. 打开VS2010解决方案tbb<version>\build\VS2010
  5. 批准将项目文件转换为使用Visual 2015工具包
  6. 选择Debug Configuration and x64 Platform和buid。 (注意如果已经完成了之前的构建,那么重新构建(清理和构建))。
  7. 将dll,pdb,lib,exp,def文件从tbb<version>\build\VS2010\intel64\Debug复制到tbb<version>\lib\Debug
  8. 创建新的空Visual C ++项目

    对debug,x64配置进行以下更改

    1. 添加其他包含目录tbb<version>\include
    2. 添加其他图书馆目录tbb<version>\lib\Debug
    3. 添加以下库依赖项

      tbbmalloc_debug.lib
      tbbmalloc_proxy_debug.lib
      tbb_debug.lib
      
    4. 选择Debug, x64配置和构建。构建成功。

    5. 用于测试的代码如下:

      #include <iostream>
      #include <vector>
      #include <random>
      
      #include <tbb/parallel_for.h>
      
      // #include "..\Headers\MexMem.hpp"
      
      using namespace std;
      
      int main() {
      
          std::vector<int> A(100, 0);
          std::vector<int> B(100, 0);
          std::vector<int> C(100, 0);
      
          mt19937_64 RandNoEngine;
          uniform_int_distribution<int> RandNoGenerator;
      
          for (int i = 0; i < A.size(); ++i) {
              A[i] = RandNoGenerator(RandNoEngine);
              B[i] = RandNoGenerator(RandNoEngine);
          }
      
          tbb::parallel_for(tbb::blocked_range<int>(0, 100), [&](tbb::blocked_range<int> &Range) {
              int beg = Range.begin();
              int end = Range.end();
              for (int i = beg; i < end; ++i) {
                  C[i] = A[i] * B[i];
              }
          });
          cout << A[30] << " * " << B[30] << " = " << C[30] << endl;
          system("pause");
          return 0;
      }
      

      按F5进行调试,此处出现错误程序无法启动,因为您的计算机缺少MSVCP120D.dll。尝试重新安装该程序以解决此问题。下一条消息与MSVCR120D.dll相关。请注意,这是在使用Visual 2015构建所有内容(包括TBB库)之后发生的。

      其他信息

      使用Dependancy Walker(depends.exe)进行快速分析会得到以下结果:

      tbb_debug.lib的依赖关系如下

      - TBB_DEBUG.dll 
         - KERNEL32.DLL
         - MSVCP140D.DLL
         - VCRUNTIME140D.DLL
         - UCRTBASED.DLL
      

      然而,Exe(上述程序的exe)中显示的tbb_debug.lib的依赖关系如下:

      - TBB_EXPERIMENT.EXE
         - TBB_DEBUG.dll
            ? MSVCP120D.DLL
            ? MSVCR120D.DLL
            - KERNEL32.
      

      为什么会出现差异?有没有办法获得更多与此相关的信息,最后,有没有办法在Visual Studio 2015上正确编译和调试英特尔TBB?

1 个答案:

答案 0 :(得分:1)

这看起来正在加载错误的TBB_DEBUG.DLL。检查Dependency Walker中DLL的完整路径。