How to install TBB from a source on Linux and make it work

I would like to know how to install TBB from a source and make it work on a Linux system. I had some problems when it comes with this, problems that do not appear if I install TBB through the package manager.

The TBB web page has some recommendations on how to do this, for example, setting the LD_LIBRARY_PATH and CPATH variables or searching for the tbbvars.sh file. Even if I do this when I try to compile the example, g ++ says that tbb was not found.

So the question is, is this an easy way to configure everything (compile the source code, which variables to set ...) to use TBB.

Thanks.

NOTE. The library version number when this question was asked was 2 (if I remember correctly). I personally tested the solution before version 4.1, but I think that it should work for the current version 4.2 (update 3) , since the construction method remains the same.

+7
source share
1 answer

I came up with a solution. I will post him here to help others with this topic.

1) Download the latest stable source code and unzip it, i.e. in ~ / tbbsrc

2) Inside make, type make. It should start compiling the tbb library and memory allocators.

3) The headers are in ~ / tbbsrc / include

4) Inside ~ / tbbsrc / build there will be two new folders, one for the release version and the other for the debug version. These folders are called "architecture_ldVersion_g ++ Version_kernelVersion".

5) I recommend setting some variables, for example, in a .bashrc file, for example:

  • TBB_INSTALL_DIR = $ HOME / tbbsrc
  • TBB_INCLUDE = $ TBB_INSTALL_DIR / include
  • TBB_LIBRARY_RELEASE = $ TBB_INSTALL_DIR / build / RELEASE_FOLDER
  • TBB_LIBRARY_DEBUG = $ TBB_INSTALL_DIR / build / DEBUG_FOLDER

6) Let's try a simple example:

 // main.cpp #include "tbb/task_scheduler_init.h" int main(int argc, char* argv[]) { // tbb::task_scheduler_init init(tbb::task_scheduler_init::automatic); // implicit tbb::task_sheduler_init::automatic tbb::task_scheduler_init init; return 0; } 

7) To compile, for example, the release version:

 g++ main.cpp -I$TBB_INCLUDE -Wl,-rpath,$TBB_LIBRARY_RELEASE -L$TBB_LIBRARY_RELEASE -ltbb 

With -Wl,-rpath,$TBB_LIBRARY_RELEASE we tell the dynamic linker where you can find libtbb.so

8) And it should work fine!

Yours faithfully!

Installation for Apple clang 5.1: [thanks rwols for the info]

Instead of typing make type make compiler=clang or make compiler=clang stdlib=libc++

+15
source

All Articles