OpenMP库规范
我是新来打开mp的人,并且尝试了来自官方网站的示例程序
i am new to open mp and i tried an sample program from the official site
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}
并且我在Eclipse中将库设置为项目Properties-> GCC c ++ linker-
and i have set the library in the eclipse as libgomp in project Properties->GCC c++ linker-
但是程序说/usr/bin/ld: cannot find -llibgomp
我可以知道我哪里错了
but the program say /usr/bin/ld: cannot find -llibgomp
can i know where i am wrong
尝试使用gomp
而不是libgomp
进行链接:库名称必须不带lib
前缀而自动传递给链接器.因此,该错误正在尝试找到liblibgomp
.不要忘记编译器标志-fopenmp
,否则OpenMP编译指示将被忽略.
Try linking with gomp
instead of libgomp
: library names must be passed to the linker without the lib
prefix, which it adds automatically. Hence the error, it is trying to find liblibgomp
. Don't forget the compiler flag -fopenmp
, otherwise the OpenMP pragmas will simply be ignored.