How to use <execution> library in c++17

淺唱寂寞╮ 提交于 2019-12-11 14:29:52

问题


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

来源:https://stackoverflow.com/questions/57084789/how-to-use-execution-library-in-c17

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!