“未定义引用‘GOACC_parallel_keyed’”以及运行 make 命令时出现的相关错误

问题描述 投票:0回答:1

我正在开展一个项目,我必须优化计算流体动力学求解器的性能。我们的目标是使用 OpenACC 来做到这一点。该求解器是使用 fortran90 编写的,并通过 Linux 系统中的终端运行。里面有build、bin、cmake、src等很多目录。我首先向每个源文件添加 OPENACC 指令,并尝试使用构建目录中的 make 命令进行编译,但遇到了一些错误。

我附上了编译器输出的一部分的屏幕截图。 SS of compiler output showing errors

fortran linker-errors openacc
1个回答
0
投票

使用 GCC,您会收到如下错误:

test.o: In function `main':
test.c:(.text.startup+0x3c): undefined reference to `GOACC_parallel_keyed'
/tmp/cc8C7CVO.crtoffloadtable.o:(.rodata+0x0): undefined reference to `__offload_func_table'
/tmp/cc8C7CVO.crtoffloadtable.o:(.rodata+0x8): undefined reference to `__offload_funcs_end'
/tmp/cc8C7CVO.crtoffloadtable.o:(.rodata+0x10): undefined reference to `__offload_var_table'
/tmp/cc8C7CVO.crtoffloadtable.o:(.rodata+0x18): undefined reference to `__offload_vars_end'
/tmp/cc0n3gC3.target.o: In function `init':
cc89TnMy.c:(.text+0x19): undefined reference to `GOMP_offload_register_ver'
/tmp/cc0n3gC3.target.o: In function `fini':
cc89TnMy.c:(.text+0x39): undefined reference to `GOMP_offload_unregister_ver'
collect2: error: ld returned 1 exit status

...如果您确实使用

-fopenacc
进行编译,但在调用 GCC 进行链接时不指定后一个标志。 (我认为构建系统不会直接调用
ld
,而是通过 GCC 进行链接。)因此,请确保
-fopenacc
在链接时也处于活动状态。

© www.soinside.com 2019 - 2024. All rights reserved.