I’ve produced a C++ program in Eclipse running on Redhat, which compiles and runs fine through Eclipse.
I thought that to run it separately to Eclipse you use the build artifact which is in the directory set via the project’s properties.
However this executable doesn’t run (I know it’s an executable as I’ve set it to be an executable via the project’s properties and it shows up as such via the ls command and the file explorer).
When attempting to run it using the executable’s name, I get the error:
bash: <filename>: command not found
When attempting to run it as a bash file:
<filename>: <filename>: cannot execute binary file
And when running it with “./” before the file name, nothing happens. Nothing new appears in the running processes and the terminal just goes to the next line as though I’d just pressed enter with no command.
Any help?
You’ve more or less figure out the first error yourself. when you just run
<filename>, it is not in your PATH environment variable, so you get “command not found”. You have to give a full or relative path when to the program in order to run it, even if you’re in the same directory as the program – you run it with./<filename>When you do run your program, it appears to just exit as soon as you start it – we can’t help much with that without knowing what the program does or see some code.
You can do some debugging, e.g. after the program just exits run
echo $?to see if it exited with a particular exit value, or run your program using the strace tool to see what it does (or do it the usual way, insert printf debugging, or debug it with gdb)