首页 > 解决方案 > 使用外部库编译 Fortran 时,“无法打开模块文件,没有这样的文件或目录”

问题描述

我目前正在尝试使用应该位于动态库 libfckit.so 中的模块来编译 Fortran 90 代码。到目前为止,我的代码是:

program debug
use fckit_mpi_module
end program debug

对于编译步骤,我使用以下命令:

mpifc -I/path/to/the/lib debug_fckit.f90 -o debug_fckit.exe

我收到以下错误:

use fckit_mpi_module
   1
Fatal Error: Can't open module file ‘fckit_mpi_module.mod’ for reading at (1): No such file or directory

我知道这是 Fortran 中的常见错误,我搜索了谷歌,但没有找到任何令人满意的解决方案。

标签: compilationfortran

解决方案


感谢 Vladimir 和 Evets 的评论帮助我解决了这个问题。我刚刚添加了模块 fckit_mpi_module.mod 和库 libfckit.so 所在目录的路径。所以现在我编译代码的命令是:

mpifc -I/path/to/the/directory/where/the/module/fckit_mpi_module.mod/is -l/path/to/the/directory/where/the/library/lifckit.so/is debug.fckit.f90 -o debug_fckit

希望这可以帮助像我这样的其他菜鸟。


推荐阅读