[英]sh: 1: /my_path/ompi-1.1/compiler/ompi: permission denied when I run my C program
I have installed a software named "OMPi" (after make
, it generated two executable file ompicc
and ompi
, and you can use ompicc -x file
to do something, and ompi
will be called by ompicc
). 我已经安装了一个名为“ OMPi”的软件(在make
之后,它生成了两个可执行文件ompicc
和ompi
,您可以使用ompicc -x file
来执行某些操作,而ompi
将被ompicc
)。
When I run the command ompicc ~/Documents/example.c
in the directory "/my_path/ompi-1.1/compiler" ( ompicc
is here and ompi
is in the sub_path "./ompi/"), an error occurred sh: 1: /my_path/ompi-1.1/compiler/ompi: permission denied . 当我在目录“ /my_path/ompi-1.1/compiler”中运行命令ompicc ~/Documents/example.c
( ompicc
在此处, ompi
在子路径“ ./ompi/”中)时,发生错误:1 :/my_path/ompi-1.1/compiler/ompi:权限被拒绝 。 But when I ran the same command in any other directories, the error didn't occur. 但是,当我在其他任何目录中运行相同的命令时,都没有发生该错误。
sudo chmod 777 -R ompi-1.1
is no use. sudo chmod 777 -R ompi-1.1
没用。
I think it may be because the sub_path "./ompi/" get the same name with file ompi
. 我认为可能是因为sub_path“ ./ompi/”与ompi
文件ompi
相同的名称。 So, I created a directory named "ompi/" in home_path, and then ran the above command. 因此,我在home_path中创建了一个名为“ ompi /”的目录,然后运行上述命令。 To my surprise, the error didn't occur. 令我惊讶的是,没有发生错误。 It seems that the error only occur when I run the command in the directory: /my_path/ompi-1.1/compiler/
似乎仅当我在以下目录中运行命令时才会出现该错误: /my_path/ompi-1.1/compiler/
From the looks of it (I have briefly checked ompi's source code), the ompi program is expected by ompicc to be in the same directory. 从外观上来看(我简要地检查OMPI的源代码),该OMPI方案由ompicc预计将在同一目录下。 It worked fine after you had created /ompi/ in home directory, because you still had executable of the same name in the same directory as ompicc . 在主目录中创建/ ompi /后,它可以正常工作,因为在与ompicc相同的目录中仍具有相同名称的可执行文件。 It doesn't work in the directory you specified because there's only one ompi there which is a directory. 它在您指定的目录中不起作用,因为那里只有一个ompi ,它是一个目录。
Line that does the execution in ompicc.c (the constructed command is then ran by a system() call: 在ompicc.c中执行的行(然后通过system()调用运行构造的命令:
sprintf(cmd, "%s%s%s \"%s.pc\" __ompi__%s%s%s%s%s%s%s %s > \"%s\"%s",
usegdb ? "gdb " : "", /* Run gdb instead of running _ompi directly */
RealOmpiName,
usegdb ? " -ex 'set args" : "", /* Pass the arguments */
/* ...further arguments here... */
To confirm that RealOmpiName is 'ompi' i followed the program and RealOmpiName is traced back to (through external symbol OmpiName) Makefile.am: 为了确认RealOmpiName是'ompi',我遵循了程序,并且RealOmpiName被追溯到(通过外部符号OmpiName)Makefile.am:
-DOmpiName='"_@PACKAGE_TARNAME@"' \
Which then is used like this (to install the software): 然后像这样使用它(安装软件):
cp -f ompi $(DESTDIR)$(bindir)/_@PACKAGE_TARNAME@
cp -f ompicc $(DESTDIR)$(bindir)/@PACKAGE_TARNAME@cc
I think the installer wouldn't put the two programs together if it didn't require the two to be in the same directory in the first place. 我认为如果安装程序首先不需要将两个程序放在同一目录中,则不会将这两个程序放在一起。
Solution: ompi and ompicc have to be in the same folder/directory. 解决方案: ompi和ompicc必须位于同一文件夹/目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.