How to statically link to TBB?

后端 未结 7 2278
忘了有多久
忘了有多久 2020-12-05 19:00

How can I statically link the intel\'s TBB libraries to my application? I know all the caveats such as unfair load distribution of the scheduler, but I don\'t need the sched

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 19:24

    Although not officially endorsed by the TBB team, it is possible to build your own statically linked version of TBB with make extra_inc=big_iron.inc.

    I have not tested it on Windows or MacOS, but on Linux, it worked (source):

    wget https://github.com/01org/tbb/archive/2017_U6.tar.gz
    tar xzfv 2017_U6.tar.gz
    cd tbb-2017_U6
    make extra_inc=big_iron.inc
    

    The generated files are in tbb-2017_U6/build/linux*release.

    When you link your application to the static TBB version:

    • Call g++ with the -static switch
    • Link against tbb (-ltbb) and pthread (-lpthread)

    In my test, I also needed to explicitely reference all .o files from the manually build TBB version. Depending on your project, you might also need to pass -pthread to gcc.

    I have created a toy example to document all the steps in this Github repository:

    • tbb-static-linking-tutorial

    It also contains test code to make sure that the generated binary is portable on other Linux distributions.

提交回复
热议问题