0

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

Community
  • 1
  • 1
Eric
  • 19
  • 4
  • In the linker section of the project properties I have added the lib folder of tbb. And I have run the batch file with the ia32 all and the intel64 all command and tried if it change something! Is that want you wanted to know? @melak47 – Eric Mar 02 '16 at 18:50
  • You've added the folder under Library Paths, but you also need to add the library under Libraries: https://i.stack.imgur.com/mxuYq.png – melak47 Mar 02 '16 at 18:55
  • @melak47 nop it is there. But what should I put in the -l option in the linker? I tried many things but it doesnt work! – Eric Mar 02 '16 at 19:02
  • The `-ltbb` is appearing in the compiler invocations, are you sure you've put it in the *linker* flags? – melak47 Mar 02 '16 at 19:05
  • If I put tbb in the -l par of the linker or -ltbb in the linker flags I get c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ld.exe: cannot find -ltbb the only place I can put it is in the compiler flag i.e. ... -ltbb -std=c++11 ... – Eric Mar 02 '16 at 19:10
  • It needs to go in the linker flags. If the linker can't find it, check if the library path is correct, and check if the library is actually called `libtbb.a` – melak47 Mar 02 '16 at 19:27
  • Linker flag ok ... library path = "C:/MinGW/tbb/tbb43_20150611oss/lib" OK how can I check if it is called libtbb.a ? – Eric Mar 02 '16 at 19:35
  • well...check that folder, see what the library's called? – melak47 Mar 02 '16 at 19:36
  • there is not a single .a in there... but i tried tbb.lib tbb.dll .... – Eric Mar 02 '16 at 19:42
  • No wonder the linker isn't finding it then... – melak47 Mar 02 '16 at 19:43
  • How I am suppose to get this file ? – Eric Mar 02 '16 at 19:46
  • Read the TBB readme, help, manual or whatnot. – melak47 Mar 02 '16 at 19:47
  • From the folder name it looks like you downloaded tbb precompiled for VC++, you may have to build it from source for MinGW, unless you find a precompiled one for your version of GCC. (For example, if you're using msys2 there's tbb packages available) – melak47 Mar 02 '16 at 19:54
  • Well I look hard but cant solve the problem! It shouldn't be that hard to get working! – Eric Mar 02 '16 at 20:09
  • @melak47 BTW I don't think this is the problem, because it is only when I use a parrallel for that I got the problem. If I only intantiate a blocked range it is OK! – Eric Mar 02 '16 at 20:13
  • It's possible that there are some header-only parts of TBB that work without linking the library. If you want to use parts that require the library to be linked though, you will need to obtain the built library. Either find a pre-built one for your compiler/toolchain, or build it yourself. – melak47 Mar 02 '16 at 20:17
  • I got the all ready build one. I have tried to download and build with the source also... still no success ! – Eric Mar 02 '16 at 20:25
  • You downloaded a pre-built one *for a different compiler*. – melak47 Mar 02 '16 at 20:26
  • And to do that it is always a ".a" file that does it ? – Eric Mar 02 '16 at 20:29
  • @melak47 well see that http://stackoverflow.com/questions/9447486/can-i-use-intels-tbb-with-gcc and also i dont see anything else on there site – Eric Mar 02 '16 at 20:45
  • Then you have to either build it yourself, or get the pre-built libraries elsewhere. This depends on the MinGW/GCC version you are using. – melak47 Mar 02 '16 at 20:46
  • can you tell me if the windows version on this link : https://www.threadingbuildingblocks.org/download is a pre-build one ? – Eric Mar 02 '16 at 20:54
  • Yes, that download has pre-built libraries, **but not for the compiler you are using** - so it doesn't help you. – melak47 Mar 02 '16 at 20:55
  • Ok I download the source. Then in the directory I input the command mingw32-make.exe compiler=gcc followed https://software.intel.com/en-us/forums/intel-threading-building-blocks/topic/291331?page=1 to help me but... i still have an error that tell me cmd is not an internal command .... common.inc:54 *** Architecture not found .... I tried it in the cmd and power shell ! @melak47 – Eric Mar 02 '16 at 22:00
  • If you're using plain old MinGW, run the MSYS Shell - there should be a .bat file called something like that in C:\MinGW – melak47 Mar 02 '16 at 22:02
  • Yes I tried that but it didnt reconize the command either... Also I cant change the directory I am in ... so i copied all the files in the good directory containing the makefile still didnt work ! – Eric Mar 02 '16 at 22:05
  • Ok I manage to get into the directory ... same error as in powershell and cmd – Eric Mar 02 '16 at 22:09
  • I really would recommend using MSYS2 and MinGW-w64, you could simply install TBB via `pacman -S mingw-w64-i686-intel-tbb`. You'd have to setup eclipse for it, though: https://stackoverflow.com/questions/32145168/configuring-eclipse-for-using-with-msys2 – melak47 Mar 02 '16 at 22:11
  • I did all you asked ... it worked ... but when I compile I get C:\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\MSYS2\mingw32\include\tbb/internal/_flow_graph_item_buffer_impl.h:28:70: fatal error: tbb/internal/_flow_graph_types_impl.h: No such file or directory – Eric Mar 02 '16 at 23:34
  • Can you share the code that produces this problem? I can compile this first example without error: https://software.intel.com/en-us/node/527509. Also, how did you install msys2, mingw-w64 and tbb? What I did was: Follow the instructions [here](https://msys2.github.io/) to install msys2, then ran `pacman -S mingw-w64-i686-gcc mingw-w64-i686-make mingw-w64-i686-intel-tbb`. (choose either x86_64 or i686 for all three) – melak47 Mar 03 '16 at 00:20
  • Yes I DL the new eclispe mars2, then mingw-w64, make sure it worked with mingw-w64 then Msys2 and the ran pacman -S ..... it worked! I did put any other tbb files in mingw-w64 my self ... I assumed It was all the command that did the job. Now I am trying with the last command you sent me. I chosse x86_64 for mingw-w64 and msys2 ... Now when I include something I only see tbb.h and a couple more not tbb/mutex,h ... – Eric Mar 03 '16 at 01:08
  • Ok I understand now I am trying with x86_64 for all the 3. – Eric Mar 03 '16 at 01:11
  • g++ -std=c++0x "-IC:\\mingw-w64\\x86_64-5.3.0-posix-seh-rt_v4-rev0\\MSYS2\\mingw32\\include\\tbb" -O0 -g3 -Wall -c -fmessage-length=0 -ltbb -std=c++11 -o "src\\test.o" "..\\src\\test.cpp" ..\src\test.cpp:1:23: fatal error: tbb/mutex.h: No such file or directory compilation terminated. – Eric Mar 03 '16 at 01:16
  • I don't think you're doing this right. 1) It looks like you installed msys2 into a standalone mingw-w64 install - that's probably not gonna work well. make a clean install of msys2 in it's own folder. When you install gcc via pacman, it will go under msys2/mingw64/bin (or 32). Then, configure eclipse to use that `msys2/mingw64` as the MinGW installation. 2) You shouldn't need to configure the include path anymore if everything is set up correctly, tbb will be installed into the msys2/mingw64/include and /lib directories, where gcc will look automatically. – melak47 Mar 03 '16 at 01:21
  • How do I install gcc via pacman ? gcc = mingw-w64 ? – Eric Mar 03 '16 at 01:54
  • `pacman -S mingw-w64-x86_64-gcc` like I wrote above. – melak47 Mar 03 '16 at 02:00
  • Sir, you are my hero! It finnaly worked! THANKS! – Eric Mar 03 '16 at 02:40
  • @melak47 if you want to copy paste my answer no problem I will vote for you. – Eric Mar 03 '16 at 02:49

1 Answers1

0

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!

Eric
  • 19
  • 4