简体   繁体   English

sh:1:/my_path/ompi-1.1/compiler/ompi:运行C程序时权限被拒绝

[英]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之后,它生成了两个可执行文件ompiccompi ,您可以使用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.compicc在此处, 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/

information in terminal 终端中的信息

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.

相关问题 运行 C 程序时出现分段错误 - Segmentation fault when i run my C program C程序未执行:权限被拒绝 - C program not executing: permission denied 运行程序时终端挂起 - Terminal hangs when I run my program 当我运行我的 C 程序时,我的编译器返回“从不兼容的指针类型‘char *’[-Wincompatible-pointer-types] 分配给‘int *’” - My compiler returned "assignment to 'int *' from incompatible pointer type 'char *' [-Wincompatible-pointer-types]" when I ran my C program 当我在我的 C 程序中运行这个 function 时,为什么会不断出现 memory 泄漏? - How come i keep getting a memory leak when i run this function in my C program? 尝试在git bash上执行C代码时获得权限被拒绝错误 - Getting permission Denied Error when trying to execute my c code on git bash 有什么方法可以在PIC电路上运行GTK程序(C)? - Is there a way i can run my GTK program (C) on a PIC circuit? popen:“ sh:权限被拒绝” - popen: 'sh: permission denied" 在Linux中运行已编译的C程序时权限被拒绝 - Permission denied when running compiled C program in Linux 在Linux Mint 15中执行C程序时,为什么会出现错误“ bash:./ a.out:权限被拒绝” - Why do I get the error “bash: ./a.out: Permission denied” when I execute a C program in Linux mint 15
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM