在Mac Terminal中运行可执行文件 [英] Running an executable in Mac Terminal

查看:1538
本文介绍了在Mac Terminal中运行可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚制作了一个.c文件,并在OS X 10.8.2的终端中使用gcc对其进行了编译.

I just made a .c file and compiled it with gcc in the terminal on OS X 10.8.2.

我的语法是gcc -o <filename> <sourcefile>,这很好.现在,我看到我有一个可执行文件,文件<filename>告诉我,但我不确定如何在双击图标/lame之外实际运行它.当我尝试通过仅键入命令来运行可执行文件时,找不到命令,但我认为它是可执行文件...?

My syntax was gcc -o <filename> <sourcefile> and that was fine. Now I see I have an executable and file <filename> tells me as such, but I'm not sure how to actually run it beside double clicking the icon, /lame. When I try running the executable by just typing I get command not found, but I thought it was executable...?

谢谢.

我太傻了,它只是打开<filename>

I"m so stupid, it was just open <filename>

推荐答案

Unix仅在系统路径上可用时运行命令,因为您可以通过$ PATH变量查看

Unix will only run commands if they are available on the system path, as you can view by the $PATH variable

echo $PATH

位于路径中不在目录中的可执行文件,除非您指定其完整位置,否则无法运行.因此,在您的情况下,假设可执行文件位于您正在使用的当前目录中,那么您可以像这样执行它

Executables located in directories that are not on the path cannot be run unless you specify their full location. So in your case, assuming the executable is in the current directory you are working with, then you can execute it as such

./my-exec

其中my-exec是程序的名称.

这篇关于在Mac Terminal中运行可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆