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

Undefined refference to tbb::task_arena_base::internal_terminate when linking

Marcel_N_
Beginner
3,227 Views

I'm trying to build a custome tbb::task_scheduler_observer for thread affinity, as shown in this example. I have a header as follows

#define TBB_PREVIEW_TASK_ARENA 1
#define TBB_PREVIEW_LOCAL_OBSERVER 1
#include "tbb/task_scheduler_observer.h"
#include "tbb/task.h"
#include "tbb/task_arena.h"

class MyObserver : public tbb::task_scheduler_observer
{
  public:
     MyObserver( tbb::task_arena &a);
     void on_scheduler_entry( bool worker );
  [...]
}

with an implementation

#include "my_observer.hpp"

MyObserver::MyObserver( tbb::task_arena& a ) : tbb::task_scheduler_observer( a )
{
    this->a_ = a;
   observe( true );
}
void MyObserver::on_scheduler_entry( bool worker )
{
  /// Two helper function that set and get the affinity mask like shown in the example 
  this->setAffinityMask( this->getAffinityMask() ); 
}

However, when linking the source code I get the following strange linking error

$ g++ -o main main.cpp my_observer.cpp -std=c++11 -ltbb

/tmp/ccx3034u.o: In function `tbb::interface7::task_arena::terminate()`:

my_observer.cpp:(.text._ZN3tbb10interface710task_arena9terminateEv[_ZN3tbb10interface710task_arena9terminateEv]+0x20): undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'

collect2: error: ld returned 1 exit status

make: *** [test] Error 1

I'm running Ubuntu 14.04 LTS with g++ version 4.8.4 and the newest release of tbb.

0 Kudos
2 Replies
Alexey-Kukanov
Employee
3,227 Views

This is strange, and my guess is that a much older version of TBB present somewhere in the system is being used by linker. The necessary entry point is present in the binaries since version 4.2 Update 1.

This StackOverflow answer http://stackoverflow.com/questions/14735387/linker-option-to-list-libraries-used can be useful to find which libraries are used by the linker.

On a side note, TBB_PREVIEW_TASK_ARENA has no effect since TBB 4.3. You still need to set TBB_PREVIEW_LOCAL_OBSERVER though.

0 Kudos
Vladimir_P_1234567890
3,227 Views

AFIAR current Ubuntu 14.04 distribution constains tbb 4.2. If you have it installed (/usr/lib/libtbb.so.2 or /usr/lib64/libtbb.so.2) it can be picked up by g++ instead of yours. -L option can be used. the note from Release notes 

    - If an open source version of Intel TBB is installed to a system
        folder like /usr/lib64 on Linux OS, examples may fail to link
        because sometimes gcc searches for libraries in an unexpected
        order. To resolve this, use the -L linker option to specify
        the right location of Intel TBB libraries. This issue does not
        affect program execution.

 

0 Kudos
Reply