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

Correct way to use TBB's CMake link target ?

nyue
Novice
511 Views

Hi,

 

  I am using the TBB CMake config as per those in the archive of 2021.7.0

 

find_package(TBB 2020 REQUIRED)

add_executable(tbbi
  main.cpp)

target_link_libraries(tbbi
  TBB::tbb)

 

However, when I compile it, it errors out and appears to be using the systems header instead of the one I provided via the TBB_DIR directive

 

I am building my application on Ubuntu 18.04

 

[ 50%] Building CXX object CMakeFiles/tbbi.dir/main.cpp.o
In file included from /usr/include/tbb/task_scheduler_init.h:24:0,
                 from /home/nyue/projects/CMakeQuestions/CMakeQuestions_git/HowToIncludeTBBInInstalPackage/main.cpp:2:
/usr/include/tbb/tbb_stddef.h:409:14: error: expected type-specifier before ‘split’
     operator split() const { return split(); }
              ^~~~~
CMakeFiles/tbbi.dir/build.make:75: recipe for target 'CMakeFiles/tbbi.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/tbbi.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/tbbi.dir/all' failed
make[1]: *** [CMakeFiles/tbbi.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2

 

Are there other targets I should use or do I need to augment the target provided by TBB config with specific <>_INCLUDE_DIRS ?

 

Kind regards

 

0 Kudos
1 Solution
nyue
Novice
502 Views

I figured out my own error. I was looking at some old TBB example that still include the now deprecated and removed header "task_scheduler_init.h" and hence it is pick up the that file.

 

I should not include that file in the first place.

 

I have studied new TBB example and the issue is resolved.

 

View solution in original post

0 Kudos
2 Replies
nyue
Novice
503 Views

I figured out my own error. I was looking at some old TBB example that still include the now deprecated and removed header "task_scheduler_init.h" and hence it is pick up the that file.

 

I should not include that file in the first place.

 

I have studied new TBB example and the issue is resolved.

 

0 Kudos
NoorjahanSk_Intel
Moderator
470 Views

Hi,

 

Thanks for posting in intel communities and sharing the solution with us.

 

Glad to know that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.

 

Thanks & Regards,

Noorjahan.

 

0 Kudos
Reply