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

梦想与她 提交于 2019-12-03 03:49:11

I have come with the solution. I'll post it here so it will help others with this topic.

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

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

3) The headers are in ~/tbbsrc/include

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

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

  1. TBB_INSTALL_DIR = $HOME/tbbsrc
  2. TBB_INCLUDE = $TBB_INSTALL_DIR/include
  3. TBB_LIBRARY_RELEASE = $TBB_INSTALL_DIR/build/RELEASE_FOLDER
  4. 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, with 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 are telling the dynamic linker where to find libtbb.so

8) And that should work fine!

Best regards!

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

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

https://github.com/wjakob/tbb seems to be the way to go.

git clone https://github.com/wjakob/tbb.git
cd tbb/build
cmake ..
make -j
sudo make install
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!