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

MinGW and TBB installation

nath02
Beginner
3,458 Views

Hi everybody !

I really need some help, here's my problem : I have to work on a project in c++ and I have to parallelise it.

I have un computer with 8 CPU's (Windows 7)and I have to work with Eclipse and MinGW.

BUT how can I install TBB with MinGW ? I mean, I read a lot of articles and documentations on Windows installation but, that's usually talking about Visual Studio and I must not use that.

How could I do tobuild TBB? Do you have any solution ? I'm completly lost and quite tired. I have already lost a lot of time on this installation and I'm quite annoyed...

If someone had succeeded in that kind of installation, could you explain to me in details how you did so ?

Really, thanks in advance, I really need your help.

Thanks again.

Here's my compilator configuration :gcc 3.4.5

0 Kudos
59 Replies
Vladimir_P_1234567890
885 Views

would the command
cmd /c"cmd /c mkdir "windows_ia32_gcc_mingw_release""
work on your machine and create the folder?

--Vladimir

0 Kudos
nath02
Beginner
885 Views

Thank you !

@Vladimir : I can't answer you now; actually, my motherboard is down, so I have to wait until tomorrow to get my computer back. I thought to install Win XP 64bits in place of Windows 7, maybe I'll have so many problems... Otherwise, I'll try your suggestion, and I'll tell you the result !

@Alexey Thank you! I'm looking forward to try it. I don't have the time at the moment to study it (I'm at school), but of course, I'll ask if I don't understand something.

Thank you, both of you !

Actually, here is the structure of my loops :

ClassFunct::ClassFunct() {

readFile();

// fill the matrix

int int_amount = int_vect.size();

for (int i=0; i

for (int j=i+1; j

//my code

}

}

}

And, I'm quite embarassed by the initialisation of second index : j : i+1

Does it create a dependence between the two loops ?

It is appropriated to use a parallel_for on the first loop ? Won't my data be corrupted ?

What do you think ?

Thanks !

0 Kudos
nath02
Beginner
885 Views
Actually, I don't see what's the my_A variable ? What's its value ?
0 Kudos
Denis_Bolshakov
Beginner
885 Views
my_A is the pointer on int.
It's a class member.
0 Kudos
Denis_Bolshakov
Beginner
885 Views
[bash]#include  //has declaration of task_scheduler_init
#include         //has declaration of parallel_for and blocked_range

class Functor
{
public:
    Functor(int** matrix, size_t amount) : m_matrix(matrix), m_amount(amount){}
    void operator()(const tbb::blocked_range& range) const
    {
        for (size_t i = range.begin(), end = range.end(); i != end; ++i)
        {
            for (size_t j = i + 1; j < m_amount; ++j)
            {
                int& elementFromMatrix = matrix;
                //please locate your code here
            }
        }
    }
private:
    int** m_matrix;
    size_t m_amount;
}

void doMyTaskParallel()
{
    size_t amount = //please init here
    int** matrix = //please init here
    tbb::parallel_for(tbb::blocked_range(0, amount), Functor(matrix, amount), tbb::auto_partitioner());
}

int main()
{
    tbb::task_scheduler_init init;
    doMyTaskParallel();
    return 0;
}[/bash]
0 Kudos
wesleygriffin
Beginner
885 Views

To follow up on this and perhaps provide a solution, as I'm attempting the same thing:

OS: Windows 7 x64
MinGW just installed, from MinGW-5.1.6.exe and MSYS-1.0.11.exe

I have upgraded the compiler:
C:\Users\wgriffin\Active\tbb>gcc -v
Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.4.0/configure --enable-languages=c,ada,c++,fortran,java,objc,obj-c++ --disable-sjlj-exceptions --enable-shared --enable-libgcj --enable-libgomp --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --prefix=/mingw --with-gmp=/mingw/src/gmp/root--with-mpfr=/mingw/src/mpfr/root --build=mingw32
Thread model: win32
gcc version 4.4.0 (GCC)

I've tried both mingw32-make (which -v reports as GNU Make 3.81) and the gnuwin32 make fromhttp://gnuwin32.sourceforge.net/packages/make.htm (also GNU Make 3.81) with identical results.

When I run:

C:\Users\wgriffin\Active\tbb>C:/msys/1.0/bin/sh.exe -c "cmd /c mkdir "windows_ia32_gcc_mingw_release""

I get a brand new command shell:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\wgriffin\Active\tbb>exit
C:\Users\wgriffin\Active\tbb>

When I run:

C:\Users\wgriffin\Active\tbb>cmd /c "cmd /c mkdir"windows_ia32_gcc_mingw_release""

It creates the directory as C:\windows_ia32_gcc_mingw_release

If I rename C:\MSYS\1.0\bin\sh.exe, then tbb builds fine (note I didn't try any of the other targets).

C:\Users\wgriffin\Active\tbb>mingw32-make compiler=gcc arch=ia32 runtime=mingw tbb

but without specifying the arch/runtime:

C:\Users\wgriffin\Active\tbb>mingw32-make tbb
cd ".\\build\\windows_unknown_cl_unknown_release" && cmd /C "..\..\build\generate_tbbvars.bat" windows_unknown_cl_unknown_release
cd ".\\build\\windows_unknown_cl_unknown_debug" && cmd /C "..\..\build\generate_tbbvars.bat" windows_unknown_cl_unknown_debug
mingw32-make -C ".\\build\\windows_unknown_cl_unknown_debug" -r -f ../../build/Makefile.tbb cfg=debug tbb_root=../..
mingw32-make[1]: Entering directory `C:/Users/wgriffin/Active/tbb/build/windows_unknown_cl_unknown_debug'
../../build/Makefile.tbb:39: CONFIG: cfg=debug arch=unknown compiler=cl os=windows runtime=unknown
cl /nologo /c /MDd /Od /Ob0 /Zi /EHsc /GR /Zc:forScope /Zc:wchar_t /DTBB_USE_DEBUG /DDO_ITT_NOTIFY /DUSE_WINTHREAD /D_CRT_SECURE_NO_DEPRECATE /D_WIN32_WINNT=0x0400 /D__TBB_BUILD=1 /W4 /I../../src /I../../src/rml/include /I../../include../../src/tbb/concurrent_hash_map.cpp
process_begin: CreateProcess(NULL, cl /nologo /c /MDd /Od /Ob0 /Zi /EHsc /GR /Zc:forScope /Zc:wchar_t /DTBB_USE_DEBUG /DDO_ITT_NOTIFY /DUSE_WINTHREAD /D_CRT_SECURE_NO_DEPRECATE /D_WIN32_WINNT=0x0400 /D__TBB_BUILD=1 /W4 /I../../src /I../../src/rml/include /I../../include ../../src/tbb/concurrent_hash_map.cpp, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make[1]: *** [concurrent_hash_map.obj] Error 2
mingw32-make[1]: Leaving directory `C:/Users/wgriffin/Active/tbb/build/windows_unknown_cl_unknown_debug'
mingw32-make: *** [tbb] Error 2

Thanks,
Wes
0 Kudos
Alexey-Kukanov
Employee
885 Views
You have to specify compiler=gcc to use TBB with MinGW.
0 Kudos
alekcac
Beginner
885 Views
Hi,
Is there any way to compile tbb under mingw-w64?
Regards,
Alexander
0 Kudos
Alexey-Kukanov
Employee
885 Views
No we did not work on support for MinGW-w64. And I do not remember anybody asking for it before.
Wanna step in and implement such support based on what we have for MinGW32? :)
0 Kudos
mazay0gmail_com
Beginner
885 Views

Well, I don't know what could be wrong with running mingw32-make on Windows 7. I tried it on my workstation, all went just fine. I don't remember if you tried another make utility - if yes, was it any different?

But anyway you should not be blocked by that, as you don't have to recompile TBB on exactly the same machine where you plan to run your app. Just copy the binaries to that machine, set up the environment properly, and you should be fine.

I tried to make TBB on Windows 7 from package tbb30_20100406oss_src.tgz with mingw32-make (GNU Make 3.81)

with this command:

mingw32-make.exe compiler=gcc arch=ia32 runtime=mingw

It just hangs and prints nothing. According to Process Explorer the procedure hangs on attempt to execute

c:\Windows\system32\cmd.exe c:/ mkdir .\build\windows_ia32_gcc_mingw_release

It is definitely wrong command because of c:/ parameter. I investigated the issue a bit and it seems to be the problem in $(shell ...) function. It transforms "cmd /c mkdir" to "c:\Windows\system32\cmd.exe c:/ mkdir" by some reason. I tried to remove "cmd /c" from makefile's but got another errors.

Same issue on Windows 2003.

Solved!!! Just remove sh.exe from all paths in %PATH%.

0 Kudos
bradleygibson
Beginner
885 Views
I found this thread as I was searching for the same thing (mingw-w64 support)... Too bad.

Roughly speaking, how big a job is that (assuming strong kung fu)?
0 Kudos
zogmachine
Beginner
885 Views
Hi, I'm new.

I have compiled the library.
I'm on windows and trying to setup this in eclipse cdt.

how exactly do i set cpath and library_path?(I did it via Properties>Environment>Add (i know this isnt eclipse forum))

visual aid: http://postimage.org/image/gav5aivaz/

Thanks
0 Kudos
Vladimir_P_1234567890
885 Views
have you added tbb.dll to your link command line?

--Vladimir
0 Kudos
palodequeso
Beginner
885 Views

I know this thread is older now but I'm still hoping someone can point me in the right direction. I'm hoping to compile tbb with mingw32 as well. As far as I can tell everything built just fine however I'm not seeing any .a or .so files get generated. Is this expected? For the visual c version there's a .lib file and in linux there is a library as well, but of course I just installed that with the package manager.

0 Kudos
Vladimir_P_1234567890
885 Views

hello, for MinGW you need to link with dll:)

--Vladimir

0 Kudos
Simon_L_1
Beginner
885 Views

I'm glad this topic was resurrected recently as it saves me apologising for doing so :)

I'm trying to compile the latest stable release (tbb42_20131003oss) under mingw-w64 with MSYS.

My mingw is from here https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/threads-win32/seh/ - the rev5 version.

My MSYS is from here https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/ - the rev13 package.

My build command for TBB is "make arch=ia32 compiler=gcc runtime=mingw SHELL=/bin/sh"

I've run into the exact same issue as others on this thread with the "mkdir" target - where there should be a /c on the resulting cmd command line, this is somehow translated to c:/, causing a hang.

I fixed this by simply removing the mkdir commands and making the directories manually.

Now my error is:

make -C ".\\build\\windows_ia32_gcc_mingw64_debug"  -r -f ../../build/Makefile.t
bb cfg=debug
'\"cscript /nologo /E:jscript ../../build/detect.js /minversion gcc 4.4\""' is not recognized as an internal or external command, operable program or batch file.
make[1]: Entering directory `/c/Users/user/dev/tbb42_20131003oss/build/windows_ia32_gcc_mingw64_debug'
../../build/Makefile.tbb:39: CONFIG: cfg=debug arch=ia32 compiler=gcc target=windows runtime=mingw64
g++ -o concurrent_queue.o -c -MMD -g -O0 -DTBB_USE_DEBUG -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D__MSVCRT_VERSION__=0x0700 -msse -mthreads -m32 -march=i686  -D__TBB_BUILD=1 -Wall -Wno-parentheses -Wno-uninitialized   -I../../src -I../../src/rml/include -I../../include ../../src/tbb/concurrent_queue.cpp
'ml' is not recognized as an internal or external command, operable program or batch file.
../../build/common_rules.inc:85: recipe for target `concurrent_queue.o' failed
make[1]: *** [concurrent_queue.o] Error 1
make[1]: Leaving directory `/c/Users/user/dev/tbb42_20131003oss/build/windows_ia32_gcc_mingw64_debug'
Makefile:40: recipe for target `tbb' failed
make: *** [tbb] Error 2

I note the failure to execute detect.js, which is similar to the failure to execute the same thing if you don't disable auto-detection of the runtime by specifying it explicitly.

I also note the user above who said his problem was solved by ensuring sh was not anywhere in %PATH% - I don't believe it is for me.

One other thing, if I run the g++ command in isolation in the appropriate directory, it works fine, so hopefully it's just the detect.js call which needs fixing.

0 Kudos
Simon_L_1
Beginner
885 Views

OK I have a successful build. I was taking a slightly wrong approach.

Instead of building under MSYS, I did the following:

1) Ensure c:\mingw-w64 (or whatever) is part of %PATH%

2) Use PowerShell!!!! Not cmd.exe, not sh.exe, not bash.exe. PowerShell. As a primarily Linux developer this was completely non-obvious to me.

3) Run mingw32-make.exe compiler=gcc

I can't find instructions on doing this anywhere - perhaps a good thing to add to the current docs?

0 Kudos
Vladimir_P_1234567890
885 Views

I used to build there in this way under cmd.exe. I'm not sure where it still works

mingw32-make.exe compiler=gcc SHELL=cmd.exe

--Vladimir

0 Kudos
Reply