Click to See Complete Forum and Search --> : stupid question


hip
01-12-2001, 02:19 AM
i a newbie to debian but i'm trying to write a simple program to get to know how things work, heres my problem:
i write the program compile it, i use make "filename.cpp", it comes out with no errors, i then try to run it ...

filename

it returns: bash: "filename":command not found
.... can someone tell me what i'm doing wrong??
thanks

Frymaster
01-12-2001, 02:30 AM
is it like this?

g++ foobar.cpp

if so, yer output will be called a.out .... so you should run it with

./a.out

also it may need to be set to executable first so try

chmod o+x ./a.out

before running it.

Larkfellow
01-12-2001, 03:01 AM
check the directory. Find out if the file is called "filename" or a.out Which ever it is type ./filename or as Frymaster said: ./a.out

hip
01-12-2001, 03:13 AM
yep that first one work, i didn't need to do that second suggestion, can u explain why i hve to do that?? why can't i just run foo??
thanks

hip
01-12-2001, 03:15 AM
there is both, if i were to doo a foo.cpp, there is a file called "foo" after compilation and it is in green colour, i dont' really know what the green means yet. There is also a.out
thanks

Larkfellow
01-12-2001, 03:20 AM
Originally posted by hip:
yep that first one work, i didn't need to do that second suggestion, can u explain why i hve to do that?? why can't i just run foo??
thanks

2 reason. 1) When you compile a program with gcc or g++ with just the filename as an arguement then your binary output file is always called a.out If you want to compile it to a specific name you just have to this:

g++ filename.cpp -o filename

2) Unless a path is in the $PATH system variable then you have to type the path to the program yourself. in this case ./a.out means run a.out in current directory. It's something you get used to. Or if you REALLY want (though it's not suggested) you can add the current directory to your PATH variable

<edit>
The green color means that the file is either a binary file or an executable file. (Sometimes you can have scripts, such as perl scripts can be executable but not binarys)
Also purple means a directory. Cyan means a "link" (points to another location, can be either a file (executable or not), or directory).

[This message has been edited by Larkfellow (edited 12 January 2001).]

Strike
01-12-2001, 04:03 AM
Check my post out on this thread: http://www.linuxnewbie.org/ubb/Forum14/HTML/001989.html

hip
01-12-2001, 05:58 AM
ok i get it now.. thanks, this should be like a NHF ... http://www.linuxnewbie.org/ubb/smile.gif . i take it that this is a linux or bsd thing cause i don't hvae to do this in solaris at uni


thanks

[This message has been edited by hip (edited 12 January 2001).]

[This message has been edited by hip (edited 12 January 2001).]

fow99
01-18-2001, 09:19 AM
This actually has been asked thousands of time in linux programmming history. maybe more than that. Don't feel bad about that. that's not a programming problem actually. thant is how you run a program under bash.
I am not laughing at you. it happended to me before.