# windows builds using msys2 - threading issues

**URL:** <https://discourse.itk.org/t/windows-builds-using-msys2-threading-issues/2648>\
**Category:** Engineering\
**Tags:** threads, simpleitk\
**Created:** [January 23, 2020, 10:53pm UTC](https://discourse.itk.org/t/windows-builds-using-msys2-threading-issues/2648 "2020-01-23T22:53:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard.beare](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@richard.beare](https://discourse.itk.org/u/richard.beare)\
**Post date:** [January 23, 2020, 10:53pm UTC](https://discourse.itk.org/t/windows-builds-using-msys2-threading-issues/2648/1 "2020-01-23T22:53:37Z")

</div>

Hi,  
Moving some long running work to discourse after discussion with @dzenanz …

My question is how to enable TBB under msys2. Detailed context below.

The error I see when enabling the TBB module is about the location of TBBConfig.cmake.

The tbb libraries appear to be installed according pacman (package names is mingw-w64-x86\_64-intel-tbb).

Any clues as to what else I need to install?

Context:  
My long term goal is to get the SimpleITK R package working under windows. R for windows is moving to a build and configuration system based around msys2. The package that can be used to build R and addon packages is [rtools40](https://cran.r-project.org/bin/windows/testing/rtools40.html). The compiler versions in use are gcc 8.3. It is possible to get access to upstream msys2 packages via a tweak to the config file.

These tools are able to build the simpleitk R package, however the tests fail because R doesn’t exit after running any ITK filters. Further investigations show that the ITK tests intermittently timeout, but pass if I set the threadcount to 1. Unfortunately the same trick doesn’t stop R freezing.

Thus I’m playing with various thread configurations to see if any work out of the box.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [January 23, 2020, 11:07pm UTC](https://discourse.itk.org/t/windows-builds-using-msys2-threading-issues/2648/2 "2020-01-23T23:07:20Z")

</div>

[PR991](https://github.com/InsightSoftwareConsortium/ITK/pull/991) and links in it might be of interest.

---

<div class="post-metadata">

**Author:** ![richard.beare](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@richard.beare](https://discourse.itk.org/u/richard.beare)\
**Post date:** [May 15, 2020, 2:58am UTC](https://discourse.itk.org/t/windows-builds-using-msys2-threading-issues/2648/3 "2020-05-15T02:58:29Z")

</div>

I am continuing to plug away with this.

On the plus side, I have got the ITK tests to pass using TBB after building with the rtools toolchain.

However, it seems that the R preference is for pthreads, as it is configured as a default to be used by the rtools compiler. To date this has lead to link issues when I get to SimpleITK, specifically with duplicate symbols from pthread libraries. I may be able to overcome these, with time.

However, I am after advice as to whether I am likely to be able to combine TBB with pthreads? While this may not happen inside SimpleITK, it looks like it is bound to occur at the R level. I have not been able to see much about this type of problem.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [May 15, 2020, 11:02am UTC](https://discourse.itk.org/t/windows-builds-using-msys2-threading-issues/2648/4 "2020-05-15T11:02:48Z")

</div>

I see no reason for TBB to clash with pthreads.
