xref: /oneTBB/doc/GSG/integrate.rst (revision 95f95117)
1.. _integrate:
2
3Integrate oneTBB
4================
5
6If you want to improve the performance and scalability of your application, you can integrate oneTBB into your project.
7For example, you may want to integrate oneTBB if your application needs to process large amounts of data in parallel.
8
9To integrate oneTBB, you need to:
10
11* Link oneTBB with the project's source code.
12* Provide the necessary compiler and linker flags.
13
14However, you can use CMake* and the pkg-config tool to simplify the process of integrating oneTBB into your project and handling its dependencies.
15See the instructions below to learn how to use the tools.
16
17CMake*
18*******
19
20CMake* is a cross-platform build tool that helps you manage dependencies and build systems.
21Integrating oneTBB into your project using CMake*:
22
23* Simplifies the process of building and linking against the library.
24* Ensures that your project can be built and run on multiple platforms.
25* Lets you manage oneTBB dependencies.
26
27To add oneTBB to another project using CMake*, add the following commands to your ``CMakeLists.txt`` file:
28
29.. code-block::
30
31       `find_package(TBB REQUIRED)`
32       `target_link_libraries(my_executable TBB::tbb)`
33
34After that, configure your project with CMake* as usual.
35
36
37Compile a Program Using pkg-config
38***********************************
39
40The pkg-config tool is used to simplify the compilation line by retrieving information about packages
41from special metadata files. It helps avoid large hard-coded paths and makes compilation more portable.
42
43To compile a test program ``test.cpp`` with oneTBB on Linux* OS,
44provide the full path to search for included files and libraries, or provide a line as the following:
45
46.. code-block::
47
48       g++ -o test test.cpp $(pkg-config --libs --cflags tbb)
49
50Where:
51
52``--cflags`` provides oneTBB library include path:
53
54.. code-block::
55
56       $ pkg-config --cflags tbb
57       -I<path-to>/tbb/latest/lib/pkgconfig/../..//include
58
59``--libs`` provides the Intel(R) oneTBB library name and the search path to find it:
60
61.. code-block::
62
63       $ pkg-config –libs tbb
64       -L<path to>tbb/latest/lib/pkgconfig/../..//lib/intel64/gcc4.8 -ltbb
65
66.. note::
67
68   For Windows* OS, additionally, use the ``--msvc-syntax`` option flag that converts the compiling and linking flags in an appropriate mode.
69