Running an executable in Mac Terminal

后端 未结 2 1710
孤街浪徒
孤街浪徒 2020-12-13 08:35

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

My syntax was gcc -o and that was fi

2条回答
  •  执笔经年
    2020-12-13 09:16

    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
    

    Where my-exec is the name of your program.

提交回复
热议问题