The key issue to prevent Xcode from running is indeed related to PATH
of gnuplot
. Depending on which package management system you use in mac, the directory of gnuplot
can vary.
Typing which gnuplot
in terminal will show the exact location of gnuplot
.
In the case of macport
, gnuplot
is located in /opt/local/bin
, which is not included in the default path setting of Xcode.
To check your PATH
, typing
std::cout << "PATH=" << getenv("PATH") << std::endl; // #include<iostream>
or
printf( "PATH=%s\n", getenv("PATH") ); // #include<cstdio>
can show you a likewise path as
/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin
Here is my solution.
The easiest way is to use a soft link to combine the real directory (/opt/local/bin
) of gnuplot
with the acceptable direction, such as ( /usr/bin
) that shows from getenv("PATH")
in Xcode, like
ln -s /opt/local/bin/gnuplot /usr/bin/gnuplot
If your .bash_profile
setting resists the previous method, then the safer and more stable method is to adding an external path in Xcode project directly,
which is original from here. In brief, add PATH
in Product>Scheme>Edit Scheme...
as shown below before closing this window.

Try this code to generate your first ever gnuplot in Xcode
#include <iostream>
#include "gnuplot-iostream.h"
int main( ) {
Gnuplot gp;
gp << "plot [-10:10] sin(x),atan(x),cos(atan(x))\n";
return 0;
}