gpt4 book ai didi

c - 源代码找不到包含头文件?

转载 作者:太空宇宙 更新时间:2023-11-04 03:42:11 26 4
gpt4 key购买 nike

我有大量的源代码,其中大部分是用 Fortran90 语言编写的,但有些部分是用 C 语言编写的。为了正确编译此代码需要安装 MPI 和 HDF5。当我尝试编译模型时,我现在已经安装了它们(编译不是使用 ./compile 命令而是使用 ./install.sh 并且它会处理所有事情,包括汇编)。我有一个很长的错误,并且都与头文件的路径有关。这是错误:

Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: stdio.h
Can't find file: math.h
Can't find file: stdlib.h
Can't find file: malloc/malloc.h
Can't find file: malloc.h
Can't find file: stdlib.h
Can't find file: errno.h
Can't find file: string.h
Can't find file: ctype.h
Can't find file: dirent.h
Can't find file: string.h

之后还有一些其他错误,我认为它们与上述错误有关。我试图在 ./bashrc 中设置 PATH,当我搜索例如 locate mpif.h 时,它返回:

[hamid@localhost bin]$ locate mpif.h
/home/hamid/Downloads/ED-2.1/ED/build/bin/mpif.h
/home/hamid/Downloads/ED-2.1/ED/src/mpi/mpif.h
/home/hamid/Downloads/mpich-3.1.3/src/binding/fortran/mpif_h/mpif.h
/home/hamid/Downloads/mpich-3.1.3/src/binding/fortran/mpif_h/mpif.h.in
/home/hamid/Downloads/mpich-3.1.3/src/include/mpif.h
/home/hamid/mpich2-optimised/include/mpif.h

我还设置了 LD_LIBRARY_PATH 变量,如:

export LD_LIBRARY_PATH=$MPI_DIR/lib:$LD_LIBRARY_PATH

但它似乎仍然不起作用。我的猜测是它不仅与 MPI 或 HDF 路径设置有关,因为其中一些是 GCC(C 编译器)头文件。知道可能是什么问题吗?

最佳答案

正如评论所说,您可以使用-I 指定目录,然后编译器会在那里找到.h 文件。例如:

gfortran -o name.o -c -I/usr/lib/openmpi/include name.f90

如果您正在使用 ifort,另一种方法是将目录附加到 FPATH,也许:

FPATH=$FPATH:usr/lib/openmpi/include

虽然这不适用于 gfortran。我不知道其他编译器。

关于c - 源代码找不到包含头文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27574787/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com