学习如何在c++17中使用执行库。我使用的是Linux,但也在我的Mac上尝试过。我知道这个错误:
致命错误:“执行”文件未找到
当我在两个操作系统中编译的时候。
我宁愿坚持使用linux,在其中输入:
g++ -g -std=c++17 ModuleDevelopmentStage13.cc -lboost_system -lboost_thread -pthread
也许我需要在这里的-l....参数中添加更多的库。我是c++新手,不知道该在哪里添加哪些?我已经安装了LLVM,并在类似的帖子上尝试了一些选项,但是没有运气。有什么建议吗?
所以在我的电脑上,我做了gcc的-v,得到了:
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
好的,所以更新-我现在切换到gcc-9.1通过自制安装。
没有像以前一样的“包含”错误,但是当我试图编译使用c++17库的简单代码示例时,我现在遇到了这个问题:
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.
我找到了丢失的图书馆,编译如下:
g++-9 -std=c++17 example.cpp -I/usr/local/Cellar/tbb/2019_U8/include/ -I/usr/local/Cellar/tbb/2019_U8/lib/
我得到了以下错误: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..........
后面跟着许多行的similar.....feel,比如im closer,但不知道如何在这一条上移动?
用g++-9 -std=c++17 example.cpp -I/usr/local/Cellar/tbb/2019_U8/include/ -L/usr/local/Cellar/tbb/2019_U8/lib/ -ltbb解析
发布于 2020-02-21 08:41:31
你需要安装tbb库。
在Ubuntu/Linux上:
$ sudo apt update
$ sudo apt install libtbb-dev在Mac上用国产啤酒:
$ brew install tbb然后在g++中链接运行时库:
g++ -g -std=c++17 ModuleDevelopmentStage13.cc -lboost_system -lboost_thread -pthread -ltbbhttps://stackoverflow.com/questions/57084789
复制相似问题