1

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.

nlsphys
  • 23
  • 1
  • 1
  • 5
  • First you need to find the directory that contains `file_descriptor.hpp`. You can do that with `find / -type f -name file_descriptor.hpp`. Once you have the directory that contains that file, say it is `/freddyfrog`, then add `-I /freddyfrog` to your compilation command - that is `dash capital i`. – Mark Setchell May 27 '16 at 22:27
  • @MarkSetchell - I have tried this and end up getting "Permission Denied" for everywhere that's being searched. I tried another command `mdfind` and this was able to locate the directory it's in. Apparently it's `working_directory/gnuplot-iostream/gnuplot-iostream.h/gnuplot-iostream.h` . This is odd because `gnuplot-iostream.h` isn't a directory, and that's the error message I get from the terminal when I use `-I /.../gnuplot-iostream/...etc`. Any ideas? – nlsphys May 28 '16 at 03:08
  • It sounds like your installation of `gnuplot-iostream` is a bit *"unhappy"*. Personally, I would extract and save any files I had created myself, remove the entire `gnuplot-iostream` installation and try afresh. – Mark Setchell May 28 '16 at 07:29
  • Sigh.. I've actually tried this already. I also updated as many things as I possibly can (e.g. xcode). I am thinking maybe I need to specify the installation (from using git clone ...) to be installed somewhere else - that somewhere else I'm not sure. – nlsphys May 28 '16 at 18:15

1 Answers1

1

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).

Yazan
  • 50
  • 6