Search code examples
c++11tbb

Compilation error with TBB on eclipse


I know there is a thread that asked a similar question and I read it, but I am still not able to clear the problem! Here is the compilation error:

    13:28:28 **** Rebuild of configuration Debug for project test2 ****
    Info: Internal Builder is used for build
    g++ "-IC:\\MinGW\\tbb\\tbb43_20150611oss\\include" -O0 -g3 -Wall -c -fmessage-length=0 -ltbb -std=c++11 -o "src\\test2.o" "..\\src\\test2.cpp" 
    g++ "-IC:\\MinGW\\tbb\\tbb43_20150611oss\\include" -O0 -g3 -Wall -c -fmessage-length=0 -ltbb -std=c++11 -o "src\\SnipSequence.o" "..\\src\\SnipSequence.cpp" 
    g++ "-LC:\\MinGW\\tbb\\tbb43_20150611oss\\lib" -o test2 "src\\test2.o" "src\\SnipSequence.o" 
    src\SnipSequence.o: In function `run':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/parallel_for.h:90: undefined reference to `tbb::task_group_context::~task_group_context()'
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/parallel_for.h:90: undefined reference to `tbb::task_group_context::~task_group_context()'
    src\SnipSequence.o: In function `ZN3tbb18task_group_contextC1ENS0_9kind_typeEj':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/task.h:450: undefined reference to `tbb::task_group_context::init()'
    src\SnipSequence.o: In function `ZN3tbb4taskC2Ev':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/task.h:553: undefined reference to `vtable for tbb::task'
    src\SnipSequence.o: In function `ZN3tbb4taskD2Ev':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/task.h:557: undefined reference to `vtable for tbb::task'
    src\SnipSequence.o: In function `ZnwjRKN3tbb8internal32allocate_root_with_context_proxyE':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/task.h:998: undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned int) const'
    src\SnipSequence.o: In function `ZdlPvRKN3tbb8internal32allocate_root_with_context_proxyE':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/task.h:1002: undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
    src\SnipSequence.o: In function `ZnwjRKN3tbb8internal27allocate_continuation_proxyE':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/task.h:1007: undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
    src\SnipSequence.o: In function `ZdlPvRKN3tbb8internal27allocate_continuation_proxyE':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/task.h:1011: undefined reference to `tbb::internal::allocate_continuation_proxy::free(tbb::task&) const'
    src\SnipSequence.o: In function `ZN3tbb10interface78internal16allocate_siblingEPNS_4taskEj':
    C:/MinGW/tbb/tbb43_20150611oss/include/tbb/parallel_for.h:120: undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
    src\SnipSequence.o:SnipSequence.cpp:(.rdata$_ZTVN3tbb10interface78internal9flag_taskE[__ZTVN3tbb10interface78internal9flag_taskE]+0x14): undefined reference to `tbb::task::note_affinity(unsigned short)'
    collect2.exe: error: ld returned 1 exit status

I have tried a lot of things in the linker section and in the include section in eclispe. I have tried to change the order of -ltbb and the -std=c++11. I still cant compile. I am sure there other people with the sample problem.

I cant solve my problem with this : stackoverflow question/answer


Solution

  • Ok First install a copy of MSYS2 in a directory. Found here : https://msys2.github.io/

    Once install open the prompt of MSYS2 and execute this line: pacman -S mingw-w64-i686-gcc mingw-w64-i686-make mingw-w64-i686-intel-tbb

    then search for the gcc.exe in the MSYS directory file and add it in your system path.

    In eclispe add C:\msys64\mingw64\lib in the -L option in the project properties, tbb in the -l option and add C:\msys64\mingw64\include in the -I option there also.

    Add -std=c++11 in the compiler flag and Voila and in the indexer if you want to get rid of certain errors only shown in Eclipse. Voila!