Error compling TBB with OpenCV4 on Centos 7

Hello There

In a ttempot to install OpenCv 4 on Centos 7, the installation process breaks up in the CMAKE building execution, when TBB compilation gets in the scene.

It seems it’s related to CMAKE centos pkg release, becasue of those syntax errors, which came up error message stack, in the building process. But I’m still investigating the root cause of it.

I’m hope someone else has gotten stuck in this situation already. So we could share some info to fasttrack the fix/solution.

Error logs are bellow
Best wishes,
I

[ 69%] Building CXX object modules/gapi/CMakeFile/opencv_gapi.dir/src/executor/gtbbexecutor.cpp.o
 In file included from /home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:7:0:
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.hpp:101:42: error: ‘tbb::task_arena’ has not been declared
 void execute(prio_items_queue_t& q, tbb::task_arena& arena);
                                      ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp: In constructor ‘cv::gimpl::parallel::detail::async::root_wait_lock_t::root_wait_lock_t(cv::gimpl::parallel::detail::tasking::root_t&, cv::gimpl::parallel::detail::async::is_tbb_work_present&)’:
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:197:41: error: ‘class tbb::task’ has no member named ‘add_ref_count’
     auto new_root_ref_count = root->add_ref_count(1);
                                     ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp: At global scope:
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:235:9: error: ‘task_arena’ in namespace ‘tbb’ does not name a type
     tbb::task_arena&                arena;
     ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:242:33: error: expected ‘)’ before ‘&’ token
     exec_ctx(tbb::task_arena& arena_, prio_items_queue_t& q_)
                             ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:245:83: error: expected unqualified-id before ‘,’ token
           tg_ctx{tbb::task_group_context::bound, tasking::tg_context_traits()},
                                                                               ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:236:41: warning: non-static reference ‘cv::gimpl::parallel::prio_items_queue_t& cv::gimpl::parallel::detail::graph::exec_ctx::q’ in class without a constructor [-Wuninitialized]
     prio_items_queue_t&             q;
                                     ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp: In lambda function:
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:334:43: error: ‘struct cv::gimpl::parallel::detail::graph::exec_ctx’ has no member named ‘arena’
                         self_copy.ctx.arena.enqueue([ready_items, self_copy, root_wait_lock]() {
                                       ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp: In function ‘void cv::gimpl::parallel::execute(cv::gimpl::parallel::prio_items_queue_t&)’:
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:371:22: error: expected type-specifier
 using attach_t = tbb::internal::attach;
                  ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:374:5: error: ‘task_arena’ is not a member of ‘tbb’
 tbb::task_arena arena{attach_t{}};
 ^
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:374:21: error: expected ‘;’ before ‘arena’
 tbb::task_arena arena{attach_t{}};
                 ^
 /home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:435:1: error: expected ‘}’ at end of input
 }
 ^
 /home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp: At global scope:
/home/qonteo/opencv/opencv/modules/gapi/src/executor/gtbbexecutor.cpp:366:6: warning: unused parameter ‘q’ [-Wunused-parameter]
 void cv::gimpl::parallel::execute(prio_items_queue_t& q) {
  ^
make[2]: *** [modules/gapi/CMakeFiles/opencv_gapi.dir/src/executor/gtbbexecutor.cpp.o] Error 1
make[1]: *** [modules/gapi/CMakeFiles/opencv_gapi.dir/all]       Error 2

feel free to disable the gapi module… if you don’t particularly need it.