我已经在 vscode 中正确安装并运行了 c/c++,我的 gcc 版本是 8.2.0 并且我已经安装了 MinGw
我使用 VS code 来运行我的 C 程序
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
int main(int argc, char* argv[])
{
int nthreads, tid;
{
tid = omp_get_thread_num();
printf("welcome to GFG from thread = %d\n", tid);
if (tid == 0){
nthreads = omp_get_num_threads();
printf("number of threads = %d\n", nthreads);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但这没有用,因为
[Running] cd "c:\cexam\" && gcc openmp_helloword.c -o openmp_helloword && "c:\cexam\"openmp_helloword
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WinstonLi\AppData\Local\Temp\ccAAWXl3.o:openmp_helloword.c:(.text+0xf): undefined reference to `omp_get_thread_num'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WinstonLi\AppData\Local\Temp\ccAAWXl3.o:openmp_helloword.c:(.text+0x33): undefined reference to …Run Code Online (Sandbox Code Playgroud)