9

Learning how to use the execution libraries in c++17. I am using Linux, but have also tried on my Mac. I get this error:

fatal error: 'execution' file not found

when i compile in both OS's.

I would rather stick with linux where i type:

g++ -g -std=c++17 ModuleDevelopmentStage13.cc -lboost_system -lboost_thread -pthread

Perhaps I need to add some more libraries in the -l.... arguments here. I am new to c++ and not sure where to find out which ones to add? I have installed the LLVM and tried a few options out there on similar posts but with no luck. Any advice?

so on my mac i did gcc -v and got:

gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target: x86_64-apple-darwin18.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Ok, so an update- I am now switched to gcc-9.1 installed via homebrew.

There are no "include" errors as before but I now have this issue when I try to compile simple code examples which use the c++17 libraries:

g++-9 -std=c++17 example.cc In file included from /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/pstl/parallel_backend.h:14, from /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/pstl/algorithm_impl.h:25, from /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/pstl/glue_execution_defs.h:52, from /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/execution:3, from example.cc:6: /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/pstl/parallel_backend_tbb.h:19:10 fatal error: tbb/blocked_range.h: No such file or directory 19 | #include <tbb/blocked_range.h> | ^~~~~~~~~~~~~~~~~~~~~ compilation terminated.

I found the missing library and compiled like:

g++-9 -std=c++17 example.cpp -I/usr/local/Cellar/tbb/2019_U8/include/ -I/usr/local/Cellar/tbb/2019_U8/lib/

I got the following error: Undefined symbols for architecture x86_64: "tbb::interface7::internal::task_arena_base::internal_current_slot()", referenced from: tbb::interface7::task_arena::current_thread_index() in ccnPixdL.o "tbb::interface7::internal::isolate_within_arena(t..........

followed by many lines of similar.....feel like im closer but no idea how to move on this one?

Resolved with g++-9 -std=c++17 example.cpp -I/usr/local/Cellar/tbb/2019_U8/include/ -L/usr/local/Cellar/tbb/2019_U8/lib/ -ltbb

smid
  • 103
  • 1
  • 7
  • 2
    Which version of GCC do you have? – Some programmer dude Jul 17 '19 at 22:36
  • 2
    And no, header files to be included with the `#include` preprocessor directive have nothing to do with linker libraries added with the `-l` (lower-case L) option. – Some programmer dude Jul 17 '19 at 22:37
  • Please [edit your question](https://stackoverflow.com/posts/57084789/edit) to include the information. There's a link also below the tags of your question. – Some programmer dude Jul 18 '19 at 14:25
  • done, I have now done an install of gcc-9.1 via homebrew and get another error (see question) – smid Jul 18 '19 at 14:37
  • Ok, I've made some progress here but now have some horrible looking error (see main question) – smid Jul 18 '19 at 15:31
  • Now it's time to learn about the options useful for libraries: The option `-I` (upper-case i) is to add a path to search for header files (`#include <...>`). The option `-L` is to add a path to look for libraries (the actual libraries, not its header files). And lastly the option `-l` (lower-case L) which is to add the library itself. Also note that you need to place the libraries (`-l`, lower-case L) last on the command line. – Some programmer dude Jul 18 '19 at 15:34
  • Thanks, I managed to fix it and it compiled and i ran the code, its a basic template but it doesnt throw error which is the main thing! – smid Jul 18 '19 at 15:40

1 Answers1

11

You need to install tbb library.

On Ubuntu/Linux:

$ sudo apt update
$ sudo apt install libtbb-dev

On Mac with Homebrew:

$ brew install tbb

Then link runtime library in g++:

g++ -g -std=c++17 ModuleDevelopmentStage13.cc -lboost_system -lboost_thread -pthread -ltbb
Alexander
  • 891
  • 11
  • 10
  • 1
    Hi, I'm linking with both '-lpthreads' and '-ltbb' (is all of this using threaded building blocks under the hood?) but I still get "'execution' file not found" I have this working on windows using visual studio but no luck on linux using clang (v9) - it stubbornly refuses to find ! – Luther May 07 '20 at 17:48
  • 1
    Maybe you need to add the library path, something like this: -L/usr/local/Cellar/tbb/2019_U8/lib/ – Alexander May 08 '20 at 14:36