Muhammad Awais Khalid February 2016

gnuplot command not working with system() function in C++

My gnuplot command is not working in my C++ program. I am trying to run gnuplot command in C++ program like this:

system("gnuplot");

It gives the error:

'gnuplot' is not recognized as an internal or external command. etc.

when I try to run gnuplot in cmd, it works fine.

Any one have idea that why gnuplot command in not working with system() function in C++?

Answers


dmi February 2016

Check whether the path to the gnuplot is in your PATH environment variable. Or alternatively, you can use the absolut path to it when calling system()


Marcus Müller February 2016

The reason is probably that the environment you execute your C++ program in doesn't tell your operating system to look in the right places to find your gnuplot executable.

Try the full path to the GNU Plot executable, include the file suffix (.exe) if you're on Windows, or make sure to set the PATH environment variable to include the directory in which your gnuplot executable is.


Muhammad Awais Khalid February 2016

Thanks you for answers friends,

I found the solution finally: After editing the environment variable $path, one has to restart the visual studio to get the latest value of environment variable. When I restarted my visual studio, it works.

So when ever you change your any environment variable, just restart visual studio (in case you are using it).

Thanks and kind regards,

Awais

Post Status

Asked in February 2016
Viewed 3,190 times
Voted 6
Answered 3 times

Search




Leave an answer