using gnuplot-iostream.h in C++

nlsphys picture nlsphys · May 27, 2016 · Viewed 8.6k times · Source

I am trying to plot data using gnuplot through a C++ program. I followed the steps from http://www.stahlke.org/dan/gnuplot-iostream/ and added the headers:

    #include "gnuplot-iostream.h"
    #include <boost/tuple/tuple.hpp>

when I compile I use

    g++ -o Ex3_3 Ex3_3.cpp -lboost_iostreams -lboost_system -lboost_filesystem

I first get this error message

    Ex3_3.cpp:18:30: fatal error: gnuplot-iostream.h: No such file or directory
    #include "gnuplot-iostream.h"
                               ^
    compilation terminated.

Okay, so then I get the file gnuplot-iostream.h from the folder gnuplot-iostream (which downloaded right into my working directory where the C++ code is) and moved it into my working directory. I then get this error message when that happens

    gnuplot-iostream.h:79:54: fatal error: boost/iostreams/device/file_descriptor.hpp: 
    No such file or directory
    #include <boost/iostreams/device/file_descriptor.hpp>
                                                  ^
    compilation terminated.

So, I am not sure what to in general. I just started learning C++ a few days ago and haven't ever used github so I'm not really sure where to go next. Does the folder have to be in your home directory? A painfully clear explanation would be appreciated.

Answer

Yazan picture Yazan · Aug 10, 2016

You need to download the interfacing code from here: https://code.google.com/archive/p/gnuplot-cpp/ And you need to install Boost library

Then you need to make sure your includes of boost lib are OK. Try to run the example code included with the interfacing files. This should work if your installation and configuration are well done.

Note that the interfacing code works with old versions of gnuplot (4.2.6).