如何设置Code :: Blocks构建选项以运行plplot?

时间:2019-02-14 14:22:02

标签: codeblocks

我找不到任何有关如何设置代码::: Blocks以运行plplot的文档。我已经在/ home / myname / plplot中安装了plplot版本5.14.0。我按照指示在https://sourceforge.net/p/plplot/wiki/Linux/进行编译。一切顺利,我在plplot文件夹中有一个build_directory和install_directory文件夹。我正在运行Ubuntu 18.04。

当我在Code :: Blocks中编译示例程序时,我不知道需要将哪些文件或文件夹添加到Project-> Build Options中。错误消息显示为:致命错误:无法打开模块文件“ plplot.mod”以在(1)处读取:没有这样的文件或目录

这是我要编译的示例:

program ft_x00f
! This is a modified version of x00f.f90
! which was written by Alan Irwin

   use plplot
   implicit none

   integer, parameter :: NSIZE = 100
   real(kind=plflt), dimension(0:NSIZE) :: x, y
   real(kind=plflt) :: xmin = 0.0_plflt, &
                       xmax = 1.0_plflt, &
                       ymin = 0.0_plflt, &
                       ymax = 100.0_plflt

   integer :: i

! Prepare data to be plotted.
! x = .00, .01, .02, ..., .99, 1.00
   x = [(i, i=0,NSIZE)] / real(NSIZE)
   y = ymax * x**2

! Parse and process command line arguments
   call plparseopts( PL_PARSE_FULL )

! Initialize plplot
   call plinit( )

! Create a labelled box to hold the plot.
   call plenv( xmin, xmax, ymin, ymax, just=0, axis=0 )
   call pllab( "x", "y=100 x#u2#d", &
               "Simple PLplot demo of a 2D line plot" )

! Plot the data that was prepared above.
   call plline( x, y )

! Close PLplot library
   call plend( )

end program ft_x00f

1 个答案:

答案 0 :(得分:0)

这个人很痛苦,但是我找到了答案。首先,即使没有Code :: Blocks,我也无法编译以上代码。我建议直接从plplot / examples目录复制一个文件,然后在Code :: Blocks中打开它。找出所需命令的最佳方法是,在安装make命令时发出make命令编译示例时,查看plplot的功能。

然后我需要在Code :: Blocks中添加以下内容-

1)项目->构建选项->链接器设置->其他链接器选项-lplplotfortran -lplfortrandemolib(注意,我从上面讨论的make命令知道这些内容)

2)项目->构建选项->搜索目录->编译器/ install_directory / lib / fortran / modules / plplot

3)项目->构建选项->搜索目录->链接器/ install_directory / lib

这至少将编译并运行一个示例。我相信创建自己的程序还有更多的乐趣。祝大家好运。

相关问题