小编Shu*_*ral的帖子

如何在vs code中安装和使用Openmp

我已经在 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)

c gcc openmp visual-studio-code

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

c ×1

gcc ×1

openmp ×1

visual-studio-code ×1