In order to get Intel TBB (Thread Building Blocks) to work with visual studio 2015, I tried the following approach (because, by default, the built binaries are only for upto vs2013).
Compile Intel TBB with Visual Studio 2015 -
- Download source code of Intel TBB from Here.
- Extract it,
- Open the VS2010 Solution
makefile.sln
with pathtbb<version>\build\VS2010
- Approve the conversion of project file to use Visual 2015 toolkit
- Select Debug Configuration and x64 Platform and buid. (note if already done previous build, then re-build (clean and build)).
- Copy the dll, pdb, lib, exp, def files from
tbb<version>\build\VS2010\intel64\Debug
totbb<version>\lib\Debug
.
Create New Empty Visual C++ Project
Make the following changes for the debug, x64 configuration
- Add additional include directories
tbb<version>\include
- Add additional Library Directories
tbb<version>\lib\Debug
Add the following library dependencies
tbbmalloc_debug.lib tbbmalloc_proxy_debug.lib tbb_debug.lib
Select
Debug, x64
configuration and Build. The Build was successful.
The Code used to test this is below:
#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;
}
Press F5 to debug, Here I get an Error of The program can't start because MSVCP120D.dll is missing from your computer. Try reinstalling the program to fix this problem. Next message is related to MSVCR120D.dll. Note that this is occurring after building everything (including the TBB Libraries) using Visual 2015.
Additional Info
A quick analysis with Dependancy Walker (depends.exe) gives the following results:
THe dependency of tbb_debug.lib
is as below
- TBB_DEBUG.dll
- KERNEL32.DLL
- MSVCP140D.DLL
- VCRUNTIME140D.DLL
- UCRTBASED.DLL
However the Dependencies of tbb_debug.lib
as shown in the Exe (exe of above program) is as below:
- TBB_EXPERIMENT.EXE
- TBB_DEBUG.dll
? MSVCP120D.DLL
? MSVCR120D.DLL
- KERNEL32.
Why the discrepancy? Is there any way to get more info related to this, and finally, is there a way to correctly compile and debug Intel TBB on Visual Studio 2015?