-   Linux - General (
-   -   Problem executing from command line (

jleyba213 04-09-2004 11:47 AM

Problem executing from command line
I just installed SuSE 9.0 on my PC and wanted to try out a simple test C++ program. It was just your standard Hello World program, and it compiled fine. But I couldn't get it to run. I typed:

And I got back somethign to the effect of:
"bash a.out not recognized"

How do I "fix" this?

Sorry that I don't have the exact error message, but I don' thave the internet working yet for SuSe and forgot to write it down, so when I switched over to windows I had to remember it off the top of my head...

Anyway, help would be greatly appreciated.

homey 04-09-2004 12:15 PM

Hopefully you have the programs already installed. The file you are making needs to be compiled first. If that works ok, it will create another file called a.out which is the execute file.
For example, I make a file called test.cpp and compile it with the command:
g++ test.cpp
Then I use the command: ./a.out to run the results.

larrykeenan 04-09-2004 12:17 PM

Two things come to my mind.
1 Did you set the permission on the file to alow it to execute?
2 If your current directory is not in your path, you need to type ./a.out

The period in the above command simply means the current directory. In most distros ~/bin is in the default path so if you create a bin directory in your home directory and put a.out there, You could run it from anywhere.

Have Fun

homey 04-09-2004 12:21 PM

You beat me to it larrykeenan! :)

I was just going to remind jleyba213 to make sure the a.out file has execute permissions

michaelk 04-09-2004 01:43 PM

In addition:
Like ./ is a shortcut for the current working directory ~ is a shortcut for your home directory i.e. /home/<user_name>/

a.out is the default executable for gcc.
gcc -o helloworld hello.c
would create an executable called hello. To run the application

See man pages gcc for additional help.

All times are GMT -5. The time now is 07:41 AM.