gpt4 book ai didi

c++ - OpenMP Mac OSX Lion c++ 链接器错误 Undefined symbols for architecture x86_64 : "_omp_get_thread_num"

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:24:25 25 4
gpt4 key购买 nike

我在互联网上的任何地方都找不到这个问题。所以我的链接器错误是:Undefined symbols for architecture x86_64: "_omp_get_thread_num()"

这是我的代码:

int nthreads;
int tid;
#pragma omp parallel private(tid)
{
tid = omp_get_thread_num();
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("number of threads: %d\n", nthreads);
}
}

最佳答案

看起来你忘了使用 -fopenmp 标志来告诉编译器你想使用 openmp,你的例子编译得很好 g++ test.cpp -fopenmp -o test在 mac osx 狮子上

关于c++ - OpenMP Mac OSX Lion c++ 链接器错误 Undefined symbols for architecture x86_64 : "_omp_get_thread_num",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12500859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com