One Way to Build Threading Building Blocks on Windows

Yesterday I successfully built and tested Threading Building Blocks on my AMD Athlon 64 X2 system, running Gentoo Linux. I had switched to that machine after having some problems with building TBB on my Intel quad-core processor machine (which is running Windows XP).

I had experimented with both the UWIN and Cygwin Unix/Linux emulators (see my "Preparing Your Windows System for OS TBB Development" Part 1 and Part 2 posts). A major snag emerged as I followed the TBB build instruction that specifies the need for GNU make and a Bourne or BASH shell. Vladimir Polin has posted comments to my "Preparing Your Windows System" blogs, saying that a Unix/Linux shell shouldn't be needed to build Threading Building Blocks on Windows. It looks to me like he is correct -- though the TBB installation method I'm about to describe does use a Cygwin installation.

Getting GNU Make onto Windows

Vladimir pointed out that when you download and uncompress the GNU make source, there is a batch file named build_w32.bat that can be run from a Windows Command Prompt (cmd.exe) window. I was able to get this to work, and gnumake.exe files were created in the WinRel and WinDebug subdirectories. However, any time I tried to run gnumake.exe from my TBB directory, a win32 exception occurred in the gnumake.exe execution. I tried the debug version of gnumake.exe, and saw a nice trail of calls -- but nothing stood out. A search for gnumake.exe throwing an exception turned up some links, but no solution.

But my objective was to build TBB, not debug my gnumake.exe problem. In "Preparing Your Windows System for OS TBB Development, Part 2" I documented the process by which I had installed Cygwin with GNU make being an included package. So, I decided to try using the Cygwin make. Within Cygwin's environment, make is found in the /usr/bin directory (enter which make at the Cygwin prompt to see this). Within the Windows environment, the Cygwin make.exe file is located in the bin directory beneath your Cygwin installation directory. In my case, Cygwin's make.exe is located in Windows directory C:\cygwin\bin. This instance of GNU make worked when I applied it to my TBB download!

Building TBB within a Visual Studio Command Prompt

I'm sure that a standard Windows Command Prompt can be used to build TBB; but I chose to launch the Command Prompt from within Visual Studio 2005 (Tools -> Visual Studio 2005 Command Prompt). This way you have all the environment variables (especially PATH) set to enable invocation of the VS command line compiler (cl) and the linker, etc.

So, in my Visual Studio 2005 Command Prompt, I navigated to the top level directory of my unpacked TBB download. I'm working with the Commercial Aligned Release, version tbb20_010oss. In that top level directory, I entered the command to execute my Cygwin-installed GNU make:


The build proceeded, successfully running all the test programs as well. Just as had happened when I built TBB on my Gentoo Linux system!

A Look at the TBB build Directory

The build actually happens within the TBB build subdirectory. During my earlier, unsuccessful attempts to build TBB, a subdirectory named windows_unknown_cl_unknown_release had been created -- suggesting to me that I had a problem with my environment. That was one of the things that led me to trying my build using the Visual Studio Command Prompt.

After my successful TBB build, I had two new directories beneath build:


The release directory has three DLLs (tbb.dll, tbbmalloc.dll, and test_model_plugin.dll); the debug directory has debug equivalents. Then, each directory contains all the TBB test executables (31 programs in all), and all the object and other files that were part of the build process. There are also *.bat, *.sh, and *.csh versions of the tbbvars file. These files set environment variables used during the build process.


I've now built and tested the open source version of Threading Building Blocks 2.0 on my Intel quad-core Windows XP system. A mysterious problem with building an executable GNU make necessitated a work-around: using the GNU make binary file that is installed as a Cygwin package. The actual build of TBB was performed in a Visual Studio 2005 Command Prompt, by executing the Cygwin GNU make executable.

Kevin Farnhan
O'Reilly Media

For more complete information about compiler optimizations, see our Optimization Notice.


anonymous's picture

I have make.exe the gnuwin32 version. I have installed make.
However, when I run make, I get the error:
make: *** create_child_process: DuplicateHandle(In) failed (e=6)

I am trying to compile \tbb20_014oss_src the comercial aligned version.
What do I need to with files in the tbb20_014oss_win folder...i cannot see
the instruction for this ?

Please send me any comments.

(name withheld)'s picture

I have the "examples" directory. When I try to build the sub_string_finder example by clicking the "sub_string_finder.sln" icon I get the following errors:
3>..\sub_string_finder.cpp(32) : fatal error C1083: Cannot open include file: 'tbb/task_scheduler_init.h': No such file or directory
3>Project : warning PRJ0018 : The following environment variables were not found:

Can you tell from these errors what I have done that's wrong?

Thanks for your help.


Kevin Farnham's picture

For those interested in Long's question, Long also asked this on the TBB Forum, and his question is being discussed there:

Kevin Farnham's picture

Jordan, the examples are packaged with the source code download. So you need to download the package ending in oss_src that corresponds with the oss_win package that you already downloaded. When you unpack the oss_src package, you'll see an "examples" directory immediately beneath the main oss_src directory.

anonymous's picture


Could someone point me in the right direction on how to implement a parallel TBB code for matrix multiplication with variable 2nd dimension, please? The example in the TBB book has fixed 2nd dimension. Thanks!


(name withheld)'s picture

I'm tryng to run the examples included in the TBB 2.0 download. I'm not sure if I unpacked and installed the files correctly. I have a c:/TBB/build directory that has a windows_ia_32_cl_vc8_debug and a windows_ia32_cl_vc8_release folder in it. These folders appear to have the correct dll and exe files in them.

Where should the examples directory be in relation to the build directory?


anonymous's picture

It didn't go away for me, any attempts to use a version built from the GNU source code failed, an exception error produced by a call to close(-1).

The Cygwin method enabled me to build 32 bit versions of tbb but not 64 bit - it doesn't seem to have a rule for .asm files for arch=emt64t.

Kevin Farnham's picture

That's interesting. I'll try that. Thanks for letting me know I'm not the only one who has seen this issue!

Vladimir Polin (Intel)'s picture

Hi, BTW we also saw "win32 exception occurred in the gnumake.exe". In our case problem went away when GNU make was recompiled in "Visual Studio Command Prompt" environment.

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.