c++ - Ubuntu 中的 Cilk Plus

标签 c++ ubuntu cilk-plus

我正在尝试在 Ubuntu 15.04 中测试以下代码。

#include <iostream>
#include <cilk/cilk.h>

using namespace std;

int main() 
{
    cilk_for(int x=0; x<10; x++) 
    {
        cout << x << endl;
    }
    return 0;
}

我收到以下错误。似乎 g++ 命令可以检测到 cilk plus 但无法以某种方式编译。

anirban@anirban-XPS-8500:~$ g++ test_cilk.cpp -lcilkplus -lcilkrts
test_cilk.cpp: In function ‘int main()’:
test_cilk.cpp:8:11: error: expected primary-expression before ‘int’
  cilk_for(int x=0; x<10; x++) 
           ^
test_cilk.cpp:8:20: error: ‘x’ was not declared in this scope
  cilk_for(int x=0; x<10; x++) 
                    ^

最佳答案

您的 g++ 命令不正确。应该是

g++ test_cilk.cpp -fcilkplus -lcilkrts
                   ^

关于c++ - Ubuntu 中的 Cilk Plus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31058547/

相关文章:

c++ - 从数组中选择一个数字

ubuntu - 将 ruby​​ 版本升级到 2.0.0 后,我的 RubyMine 版本 4.0.1 上的 Debug模式停止工作

c++ - 为什么这段代码会导致死锁?

c++ - 在 C++ 中是否有 “right” 原型(prototype)函数的方法?

c++ - 用提升解释整数比较

c++ - QMYSQL 驱动程序未在发行版中加载,正在调试中工作

ubuntu - Ansible 是否有可以重新获取剧本执行历史记录的文件或命令?

r - 将 kable 导出到镜像时的 XDG_RUNTIME_DIR (Rstudio + Ubuntu 20.04)

c++ - 在 Mac OS X (El Capitan) 上安装 Cilk Plus 时出错