在fortran中使用fgsl:如何使用gfortran进行编译 [英] Use fgsl in fortran: how to compile with gfortran
问题描述
我正在尝试做一些基本的事情,但是我找不到有关如何编译的相关信息.我尝试了以下方法,但均未成功:
I am trying to do something basic, but I can't find the relevant information on how to compile. I tried the following without success:
gfortran testintegral.f90 -lgsl -lgslcblas
testintegral.f90:19.6:
use fgsl
1
Fatal Error: Can't open module file 'fgsl.mod' for reading at (1): No such file
该文件来自 http://de.wikibooks.org/wiki/Fortran:_FGSL#Beispiel:_Numerische_Integration (德语页面,但易于理解),所以我认为可以.
The file is taken from http://de.wikibooks.org/wiki/Fortran:_FGSL#Beispiel:_Numerische_Integration (page in german but readily understandable) so I suppose it is OK.
也许编译命令的语法不正确?
Maybe the syntax of the compilation command is incorrect ?
我编辑我的第一篇文章,以免在评论中掩盖重要信息.
I edit my initial post so as not to bury important information in the comments.
这些是库的路径:
sudo find -name '*libgsl.so*'
./usr/lib/libgsl.so.0
./usr/lib/libgsl.so.0.17.0
sudo find -name '*libgslcblas.so*'
./usr/lib/libgslcblas.so.0
./usr/lib/libgslcblas.so.0.0.0
但是在执行此操作时,我仍然收到错误消息:
But I still got an error message when doing:
gfortran testintegral.f90 -L/usr/lib -I/usr/include/fgsl -lfgsl -lgsl -lgslcblas
/usr/bin/ld: cannot find -lgsl
/usr/bin/ld: cannot find -lgslcblas
collect2: error: ld returned 1 exit status
推荐答案
使用 -I
标志.例如,
gfortran -I/usr/local/fgsl/include testintegral.f90 -lgsl -lgslcblas
然后包括该目录中的所有.mod文件.
All the .mod files in that directory are then included.
另请参见下面的评论.
这篇关于在fortran中使用fgsl:如何使用gfortran进行编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!