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

How to install TBB library in Ubuntu

leileicats
Beginner
2,926 Views
Hi, I'm a novice to Linux and TBB. I am asking help for how to build TBB in Ubutu.
I have already downloaded the source file: tbb20_20070927oss_src. And then I enter the directory and 'make': ~/tbb20_20070927oss_src/$ make

After running a bunch of stuff, I still can't compile TBB sample code.
My sample code:
#include "tbb/task_scheduler_init.h"

using namespace tbb;

int main() {
task_scheduler_init init;
return 0;
}

When I's using g++ compile, it shows:
/tmp/cccwYHds.o: In function `tbb::task_scheduler_init::task_scheduler_init(int)':
tbbtext.cpp:(.text._ZN3tbb19task_scheduler_initC1Ei[tbb::task_scheduler_init::task_scheduler_init(int)]+0x28): undefined reference to `tbb::task_scheduler_init::initialize(int)'
/tmp/cccwYHds.o: In function `tbb::task_scheduler_init::~task_scheduler_init()':
tbbtext.cpp:(.text._ZN3tbb19task_scheduler_initD1Ev[tbb::task_scheduler_init::~task_scheduler_init()]+0x16): undefined reference to `tbb::task_scheduler_init::terminate()'
collect2: ld returned 1 exit status

I guess I failed to install TBB on my machine. Could anyone give some help?
0 Kudos
4 Replies
leileicats
Beginner
2,926 Views
I copy share library in the directory ~/lib/libtbb.so. Then my command line:
g++ tbb.cpp -o tbb -L/~/lib/ -ltbb
And it works!!!

I also install the tbb package ( a bunch of .deb files ). I could find the file tbb(there are a bunch of *.h files) in the directory as /usr/include/tbb which is the same as my boost libraries /usr/include/boost.

But now the question is:
When I am using boost libraries,
#include

int main() {
boost::dynamic_bitset<> bitsetting;
return 0;
}

the command line as: $ g++ -o test test.cpp. There is no error.

However when I am using TBB libraries,

#include

int main() {
tbb::task_scheduler_init init;
return 0;
}

It will pop out those errors when I am using $ g++ -o test test.cpp. I don't know why?
The only difference is that I install the boost libraries through Synaptic Package Manager, but as to the TBB libraries, I am using dpkg --install ***tbb**.deb to install TBB libraries. Should I modify some enviromental settings?
0 Kudos
Vladimir_P_1234567890
2,926 Views
Looks like libtbb.so is out of environement.Does$LIB variable point to folder with libtbb.so file?
0 Kudos
Alexey-Kukanov
Employee
2,926 Views

leileicats:
But now the question is:
When I am using boost libraries,
#include

int main() {
boost::dynamic_bitset<> bitsetting;
return 0;
}

the command line as: $ g++ -o test test.cpp. There is no error.

However when I am using TBB libraries,

#include

int main() {
tbb::task_scheduler_init init;
return 0;
}

It will pop out those errors when I am using $ g++ -o test test.cpp. I don't know why?

I am not an expert in Boost so may be incorrect, but I think the difference is that for boost/dynamic_bitset all its implementation is in the header file so there is no need for any library to link with. TBB classes are mostly different, they call other classes or some functions instantiated in the TBB .so files. Thus you need to provide -ltbb to the compiler (or more precisely, thelinker); like as you would dowith, say, the POSIX thread library which use has to be explicitly specified with -lpthread.

0 Kudos
leileicats
Beginner
2,926 Views
Thank you very much for your information. I think I have figured out what is the problem.
0 Kudos
Reply