I want TBB to work, but it's hard for me to put together work on Ubuntu 14.04. I think this is probably the problem with setting the library location for the compiler.
I installed TBB using the following command:
sudo apt-get install libtbb-dev
I have a small test case that I'm trying to compile now. The code is as follows:
#include "tbb/task_scheduler_init.h" int main(int argc, char* argv[]) { tbb::task_scheduler_init init; return 0; }
The command that I run to compile this code is as follows:
g++ -std=c++11 -g -O2 -ltbb simple_test.cc -o simple_test
I run this using g ++ version 4.9.1. When I try to compile, I get the following errors:
/tmp/cc7Ls8Sb.o: In function `task_scheduler_init': /usr/include/tbb/task_scheduler_init.h:126: undefined reference to `tbb::task_scheduler_init::initialize(int, unsigned long)' /tmp/cc7Ls8Sb.o: In function `~task_scheduler_init': /usr/include/tbb/task_scheduler_init.h:132: undefined reference to `tbb::task_scheduler_init::terminate()' collect2: error: ld returned 1 exit status
The location of the task_scheduler_init.h file is /usr/include/tbb/task_scheduler_init.h .
Could you imagine what I am doing wrong?
EDIT: I reordered the arguments for g ++, and this made it work:
g++ simple_test.cc -std=c++11 -g -O2 -ltbb -o simple_test
I really don't understand why this change made compilation successful.
source share