I'm new to gnuplot and was trying to just make a plot of random numbers to visualize the distribution of the psuedo-random rand()
function in c++. However, I came across a problem that appears common: the path was not found for gnuplot.exe.
Possible relevant information before I go on:
Running Windows 10 64-bit. Compiler: CLion. gnuplot.exe path: C:\Program Files (x86)\gnuplot\bin
I have the latest version of gnuplot form sourceforge (as of 10/21/19: 5.2.7 I believe).
I have already checked these questions:
gnuplot-cpp cannot feed command to pipe
Gnuplot & C++: Can't find gnuplot neither in PATH nor in "
I've looked through many other questions but they weren't as relevant to the problem I have. I tried implementing the answers there and did not make any progress. I have the same gnuplot_i.hpp file and changed the problem line to:
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
std::string Gnuplot::m_sGNUPlotFileName = "gnuplot.exe";
std::string Gnuplot::m_sGNUPlotPath = "C:/Program_Files(x86)/gnuplot/bin/";
I also have the correct PATH
set for gnuplot as a environmental variable and can execute gnuplot
from cmd.
The errors I've gotten were:
Cannot find gnuplot neither in PATH nor in "C:/Program_Files(x86)/gnuplot/bin"
and, when I removed the "_" from the path above and replaced it with a space:
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
This last one is the only one that appears now, even though I do not have the space anymore, as it's been mentioned that having spaces in the path is a known bug with gnuplot. I am aware that Program_Files(x86)
is not a real path, I was just trying to get rid of the second error message.
My main.cpp, if it even matters:
#include <iostream>
#include "gnuplot_i.h"
#include <cstdlib>
#include <vector>
using namespace std;
int main(int argc, char* argv[]) {
try {
Gnuplot rand_plot("lines");
}
catch (GnuplotException ge) {
cout << ge.what() << endl;
}
return 0;
}
Any help on solving these errors would be greatly appreciated.
Botje in the comments solved the issue. Changing lines 1714-1715 in gnuplot_i.h
to std::string tmp = std::string("\"") + Gnuplot::m_sGNUPlotPath + "/" + Gnuplot::m_sGNUPlotFileName + std::string("\"");
fixed the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.