开发者

How do you run a command line program after compiling with GCC on OSX?

Some of Facebooks programmer puzzles look fun, so I'm trying to get set up to code in C++ on my mac. I decided to try compiling some of my old 开发者_Python百科CS homework with GCC to get started.

My code compiles fine, but when I try to run the executable (called "encrypt") I get this:

-bash: encrypt: command not found

I checked the permissions on the file and it seems to have execute permission. What am I missing here?


The current directory isn't in your $PATH, so you have to tell the shell to execute encrypt in the current directory.

./encrypt

or

/path/to/directory/encrypt


You need to execute it as ./encrypt


Try ./encrypt rather than encrypt. Bash won't look for executables with relative paths outside the path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜