sh: gnuplot: 在 Gnuplot + Xcode 中找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22815583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
sh: gnuplot: command not found in Gnuplot + Xcode
提问by darknessReigns
There was a similar question to mine however the answers were not quite solutions so if I could get some help with this it would be greatly appreciated.
有一个与我类似的问题,但答案并不完全是解决方案,因此如果我能得到一些帮助,将不胜感激。
The problem is that when I compile, Xcode gives the aforementioned error of sh: gnuplot: command not found.
问题是当我编译时,Xcode 给出了 sh: gnuplot: command not found 的上述错误。
I checked which gnuplot
in terminal and as expected from macports it is in /opt/local/bin/gnuplot
. Also printf("PATH=%s\n", getenv("PATH"));
shows the path PATH=/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
I suspect therein lies the problem but I am not sure how to fix it.
我检查which gnuplot
了终端,正如 macports 预期的那样,它在/opt/local/bin/gnuplot
. 还printf("PATH=%s\n", getenv("PATH"));
显示了PATH=/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
我怀疑其中存在问题的路径,但我不确定如何解决它。
Thanks in advance!
提前致谢!
采纳答案by trojanfoe
Replace occurrences of gnuplot
, in your script, with /opt/local/bin/gnuplot
to take $PATH
out of the equation.
更换的出现gnuplot
,在你的脚本,以/opt/local/bin/gnuplot
采取$PATH
等式出来。
回答by Yeeson
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.
关键的问题,以防止Xcode的运行确实涉及到PATH
的gnuplot
。根据您在 mac 中使用的包管理系统,目录gnuplot
可能会有所不同。
Typing which gnuplot
in terminal will show the exact location of gnuplot
.
which gnuplot
在终端中输入将显示gnuplot
.
In the case of macport
, gnuplot
is located in /opt/local/bin
, which is not included in the default path setting of Xcode.
在macport
,gnuplot
位于的情况下/opt/local/bin
,它不包含在 Xcode 的默认路径设置中。
To check your PATH
, typing
要检查您的PATH
,请键入
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
/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
) ofgnuplot
with the acceptable direction, such as (/usr/bin
) that shows fromgetenv("PATH")
in Xcode, likeln -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, addPATH
inProduct>Scheme>Edit Scheme...
as shown below before closing this window.
最简单的方法是使用软链接结合实际目录(
/opt/local/bin
)的gnuplot
与可接受的方向,如(/usr/bin
),其从显示getenv("PATH")
在Xcode,像ln -s /opt/local/bin/gnuplot /usr/bin/gnuplot
如果你的
.bash_profile
设置抵触前面的方法,那么更安全稳定的方法是直接在Xcode工程中添加外部路径,原文出自这里。总之,添加PATH
在Product>Scheme>Edit Scheme...
为关闭该窗口前图所示。
Try this code to generate your first ever gnuplot in Xcode
尝试使用此代码在 Xcode 中生成您的第一个 gnuplot
#include <iostream>
#include "gnuplot-iostream.h"
int main( ) {
Gnuplot gp;
gp << "plot [-10:10] sin(x),atan(x),cos(atan(x))\n";
return 0;
}