OpenMP library specification

折月煮酒 提交于 2019-12-13 12:09:48

问题


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());
}

and i have set the library in the eclipse as libgomp in project Properties->GCC c++ linker-

but the program say /usr/bin/ld: cannot find -llibgomp can i know where i am wrong


回答1:


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.




回答2:


Add gomp to GCC C++ Linker->Libraries. Then add −fopenmp to the Miscellaneous flags for GCC C++ Compiler, GCC C Compiler, and GCC C++ Linker



来源:https://stackoverflow.com/questions/3904825/openmp-library-specification

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