【问题标题】:How do I set up Code::Blocks build options to run plplot?如何设置 Code::Blocks 构建选项来运行 plplot?
【发布时间】:2019-02-21 11:26:43
【问题描述】:

我找不到任何关于如何设置 Code::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中添加哪些文件或文件夹。错误消息显示:致命错误:无法在 (1) 处打开模块文件“plplot.mod”进行读取:没有这样的文件或目录

这是我正在尝试编译的示例:

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

【问题讨论】:

    标签: codeblocks


    【解决方案1】:

    这个很痛苦,但我已经找到了答案。首先,即使没有 Code::Blocks,我也无法编译上述代码。我建议直接从 plplot /examples 目录复制一个文件并在 Code::Blocks 中打开它。找出需要哪些命令的最好方法是查看在安装 plplot 时发出 make 命令编译示例时 plplot 做了什么。

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

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2016-01-24
      • 1970-01-01
      • 1970-01-01
      • 2016-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多