The issue
I am trying to use the execution policies in the standard algorithm library. However, when I try to compile I get the following error message
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\pstl\parallel_backend_tbb.h:19:10: fatal error: tbb/blocked_range.h: No such file or directory
After looking at various other related questions such as this or this, I understand that the execution
library depends upon a software called tbb
. Moreover in order to compile code which uses <execution>
one has to manually link to tbb
. My issue is precisely with how to download and link tbb
to a script that uses <execution>
.
I believe I have some serious gaps in my understanding in terms of how one downloads the correct files and then links to them. I will first make a list with my understanding of the linking process and then I will explain what I have tried to fix the issue. I have chosen this format so that it is faster for the one to answer my question to point at the issue at fault. I will attempt to keep this as concise as possible.
My understanding
- Code is organized in header and
cpp
files, where the former usually only contain the interface to the software and the later the implementation - The
cpp
files can be pre-compiled and grouped into a single library file - For a user to then use the library, they have to
#include
the header/s in their script and also tell the compiler where the header files as well as the library file, are located - This can be done with the
-I
for the headers and-L
,-l
for the library file -L
provides the location of the library files, the-l
specifies which libraries to use
What I tried
The script I try to compile is:
#include <execution>
int main() {
std::execution::par;
return 0;
}
with
g++ script.cpp -o out -I C:(path to the headers) -L C:(path to the library) -l (name of library) -std=c++17
I should also mention I am trying to do this on Windows 10
1st attempt
I had a particularly hard time understanding where to find the header and library files for tbb
.
In the Intel getting started with TBB webpage, this github repository is listed as "TBB being available at". As I am used to header-only libraries I thought everything would be in the include directory but no .dll
files where there. It is now my understanding that I have to compile the DLLs myself for my specific system which makes sense. I followed the following process using cmake
:
# Do our experiments in /tmp
cd /tmp
# Clone oneTBB repository
git clone https://github.com/oneapi-src/oneTBB.git
cd oneTBB
# Create binary directory for out-of-source build
mkdir build && cd build
# Configure: customize CMAKE_INSTALL_PREFIX and disable TBB_TEST to avoid tests build
cmake -DCMAKE_INSTALL_PREFIX=/tmp/my_installed_onetbb -DTBB_TEST=OFF ..
# Build
cmake --build
# Install
cmake --install .
# Well done! Your installed oneTBB is in /tmp/my_installed_onetbb
However at the cmake --build
step, cmake
does not accept the command but requests more options. One of them is the dir
option, which for which I made another directory and supplied it but then the error message Error: could not load cache
printed out.
In any case, some files had been created so I searched for the .dll
file but could not find it.
2nd attempt
I downloaded the Intel oneAPI Base Toolkit as is suggested here. After the installation at ../Program Files (x86)/Intel/oneAPI
I found the specific tbb
tool at C:\Program Files (x86)\Intel\oneAPI\tbb
and I used this address for the -I
and -L
flags but initial error message persists.
I also copied the directory C:\Program Files (x86)\Intel\oneAPI\tbb\2021.6.0
to the local directory of the script so I could link with -flag tbb\2021.6.0
but no luck
Many thanks