Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

How to compile a tbb program

ebymohan
Beginner
1,339 Views
i just started studing TBB a few days ago i hav read a lot
but to better understand i need to execute some programs
i hav downloaded VS 2010 and intel parelel studio
i can execute the compiled examples given in the site
but cant compile the code gives me error like library files missing
plz tell me how to add lib files
0 Kudos
1 Solution
ARCH_R_Intel
Employee
1,339 Views
In the Solution Explorer menu, right click your project, and go to Properties. Then set two things:
  • Configuration Properties C++ General Additional Include Directories: Add $(TBB30_INSTALL_DIR).
  • Configuration Properties Linker Additional Library Directories: Add $(TBB30_INSTALL_DIR)\lib\ia32\vc10)

You can look at these settings on the example projects to see the proper settings. They might differ from what I have above, which I copied from a VS2010 project of mine that I happen to have open at the moment.

View solution in original post

0 Kudos
4 Replies
Krishna_R_Intel
Employee
1,339 Views
Hi,
Have you tried the "Getting Started" document that comes with every copy of Intel TBB? It has detailed information about how you could compile and run your program that uses Intel TBB.

Thanks,
Krishna
0 Kudos
ebymohan
Beginner
1,339 Views
1st of all thanks for the reply
yes i hav
and i hav installed VS2010 and intel parallel studio(both evaluation version)
i can execute the programs provided with the package that has VS solution file in it
but cannot even compile the same when i copy paste the source into a newly created file or c++
for example i cannot compile the following code(this is a example (substring finder) comming along with the package)
#include
#include
#include
#include "tbb/parallel_for.h"
#include "tbb/blocked_range.h"
using namespace tbb;
using namespace std;
static const size_t N = 23;
class SubStringFinder {
const string str;
size_t *max_array;
size_t *pos_array;
public:
void operator() ( const blocked_range& r ) const {
for ( size_t i = r.begin(); i != r.end(); ++i ) {
size_t max_size = 0, max_pos = 0;
for (size_t j = 0; j < str.size(); ++j)
if (j != i) {
size_t limit = str.size()-max(i,j);
for (size_t k = 0; k < limit; ++k) {
if (str[i + k] != str[j + k]) break;
if (k > max_size) {
max_size = k;
max_pos = j;
}
}
}
max_array = max_size;
pos_array = max_pos;
}
}
SubStringFinder(string &s, size_t *m, size_t *p) :
str(s), max_array(m), pos_array(p) { }
};
int main() {
string str = { string("a"), string("b") };
for (size_t i = 2; i < N; ++i) str = str[i-1]+str[i-2];
string &to_scan = str[N-1];
size_t num_elem = to_scan.size();
size_t *max = new size_t[num_elem];
size_t *pos = new size_t[num_elem];
parallel_for(blocked_range(0, num_elem ),
SubStringFinder( to_scan, max, pos ) );
for (size_t i = 0; i < num_elem; ++i)
cout << " " << max << "(" << pos << ")" << endl;
delete[] pos;
delete[] max;
return 0;
}
this is a example (substring finder) comming along with the package
compiling this gives following errors
1>------ Build started: Project: dx, Configuration: Debug Win32 ------
1>Build started 12/15/2010 4:59:03 PM.
1>ClCompile:
1> ***** ClCompile (Win32 - Intel C++)
1> compilation aborted for dx.cpp (code 4)
1> dx.cpp
1>dx.cpp(4): error : cannot open source file "tbb/parallel_for.h"
1> #include "tbb/parallel_for.h"
1> ^
1>
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.56
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
0 Kudos
ARCH_R_Intel
Employee
1,340 Views
In the Solution Explorer menu, right click your project, and go to Properties. Then set two things:
  • Configuration Properties C++ General Additional Include Directories: Add $(TBB30_INSTALL_DIR).
  • Configuration Properties Linker Additional Library Directories: Add $(TBB30_INSTALL_DIR)\lib\ia32\vc10)

You can look at these settings on the example projects to see the proper settings. They might differ from what I have above, which I copied from a VS2010 project of mine that I happen to have open at the moment.

0 Kudos
ebymohan
Beginner
1,339 Views
Thank u very much to both of u
now i can study this in more detail
as for now everything works fine
0 Kudos
Reply