c++gccg++osx-mountain-lion

Why wont my executable run when I type the name? (Mac OS X Mountain Lion) Mac OS X 10.8.2


I'm trying to run my program from XQuartz (X11) terminal and when I compile my executable doesn't have an asterisk on it and it won't run. It says that the command not found when I type the name. I was using Xcode at one point and I've downloaded Command-Line Tools. Why is this and what do I have to do to fix this?


Solution

  • If you've compiled it to a binary, in the folder in which the binary exists, run it with ./binary-name. Normally, it should run. But if it says the binary is not executable (very unlikely), set the executable permission with chmod +x binary-name.

    Usually, if the executable is not in PATH, you have to prepend it with ./ to run it.