【问题标题】:gnuplot in c++ - path error [duplicate]c ++中的gnuplot - 路径错误[重复]
【发布时间】:2014-05-18 18:29:46
【问题描述】:

我正在尝试从该站点实现以下代码:

https://sites.google.com/site/bettereaclone/introduction/gnuplot/c-example-gnuplot-1

代码:

#include <iostream>
#include "gnuplot_i.hpp"
#include <windows.h>
#include <conio.h>
using std::cout;
using std::endl;
int main(int argc, char* argv[])
{
    try
    {
        Gnuplot g1("lines");
        cout << "*** plotting slopes" << endl;
        g1.set_title("Slopes\\nNew Line");

        cout << "y = x" << endl;
        g1.plot_slope(1.0,0.0,"y=x");

        cout << "y = 2*x" << endl;
        g1.plot_slope(2.0,0.0,"y=2x");

        cout << "y = -x" << endl;
        g1.plot_slope(-1.0,0.0,"y=-x");
        g1.unset_title();
    }
    catch (GnuplotException ge)
    {
        cout << ge.what() << endl;
    }
    return 0;
}

我安装了 gnuplot (http://www.gnuplot.info/download.html)

gnuplot_i.hpp 文件 (https://code.google.com/p/gnuplot-cpp/source/browse/trunk/gnuplot_i.hpp)

当我运行这段代码时,我遇到了这个问题:

错误:

'C:/Program' 未被识别为内部或外部命令, 可运行的程序或批处理文件。

我不知道为什么。谢谢!!

【问题讨论】:

  • 您正在重定向到一段代码。我建议您将问题隔离到可重现的代码 sn-p。 SO 不是代码审查论坛。
  • 让我尝试解决这个问题.. 因为我真的不知道如何发布它.. 但我会解决
  • 没错,是一回事!有没有办法关闭这个帖子?我标记了这个问题。

标签: c++ gnuplot


【解决方案1】:

看起来 gnuplot 的路径格式不正确,不在引号中或根本无法正确读取。

尝试通过取消注释此行并将其更正为指向您机器上的 gnuplot 目录来强制路径:

// Gnuplot::set_GNUPlotPath("C:/program files/gnuplot/bin/");

【讨论】:

  • 我在“尝试”之前尝试过,但没有任何改变:(
  • 也可以尝试用引号括起来的路径:Gnuplot::set_GNUPlotPath("\"C:/program files/gnuplot/bin/\"");
  • 同样的错误...我也尝试将 C:/Program Files 替换为 C:\Proga~1 并且没有用.
  • 我最后的想法是将gnuplot重新安装到路径中没有空格的目录。
  • 我可以试一试,但我会再等一会再尝试其他的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-01
  • 2017-11-15
  • 2014-01-17
  • 1970-01-01
  • 2021-09-02
  • 1970-01-01
相关资源
最近更新 更多