LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-26-2008, 10:11 AM   #1
phanipalagummi
LQ Newbie
 
Registered: Nov 2008
Posts: 23

Rep: Reputation: 15
gcc help


in a book i saw that (complete reference to gcc)

Quote:
hello.out
(just typing in the terminal)

gives the executable result of hello.out

but it says to me command not found

could any one help me,and please tell me how to get the result of a executable
 
Old 11-26-2008, 10:21 AM   #2
unihiekka
Member
 
Registered: Aug 2005
Distribution: SuSE Linux / Scientific Linux / [K|X]ubuntu
Posts: 273

Rep: Reputation: 32
First off, that is only true if a) hello.out exists and b) the executable is in your $PATH. Assuming that hello.out exists, then you can simply type

Quote:
./hello.out
in the directory of hello.out. The ./ tells your terminal to look in the current directory.

Just as a little advice: gcc has the -o option where you can give the executable after (successful) compilation whatever name you want, e.g.:

Quote:
gcc -o My_Executable_File_Name Input_File.cpp
where Input_File.cpp is your source code.
 
Old 11-26-2008, 10:29 AM   #3
phanipalagummi
LQ Newbie
 
Registered: Nov 2008
Posts: 23

Original Poster
Rep: Reputation: 15
[HTML]dheera@dheera-desktop ~ $ ls
Desktop hanumaan.c #*mail*#6153uil# NetBeansProjects untitled folder
dwhelper hanumaan.o #*mail*#6312Dtl# p Videos
Examples hello.c movies phanindra notes video songs
hanumaan hello.c~ myc Photos wall papers
#hanumaan.c# hellow naruto episodes Pictures
[/HTML]

after
Code:
gcc hello.c
i got this as out put

[HTML]dheera@dheera-desktop ~ $ ls
a.out #hanumaan.c# hellow naruto episodes Pictures
Desktop hanumaan.c #*mail*#6153uil# NetBeansProjects untitled folder
dwhelper hanumaan.o #*mail*#6312Dtl# p Videos
Examples hello.c movies phanindra notes video songs
hanumaan hello.c~ myc Photos wall papers
[/HTML]

after
Code:
a.out
i got this as

[HTML]dheera@dheera-desktop ~ $ a.out
bash: a.out: command not found
[/HTML]
 
Old 11-26-2008, 12:56 PM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,513

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The command 'echo $PATH' will output where you can place
an executable and expect it to work.

For all other locations, you will have to do the full path,
e.g. '/home/dheera/Desktop/a.out' or 'cd' to e.g. Desktop
and start the command with a dot : './a.out'
( The dot means the current directory )

And who says that all text in that book is correct ??
 
Old 11-27-2008, 05:00 AM   #5
nehaandrew
Member
 
Registered: Nov 2008
Posts: 53

Rep: Reputation: 15
the ./ command is needed to be appended to the file you wish to execute.

if your executable abc.out is under the /home/myhome/testing folder

you would need to do this:
cd /home/myhome/testing folder
./abc.out


I hope this helps!


Linux

Last edited by nehaandrew; 11-30-2008 at 01:22 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why gcc is needed for an HBA card? How to upgrade gcc enayet_v Linux - Newbie 3 11-17-2007 04:57 AM
LXer: Tools: GCC 3.4.6, Final GCC 3 Release LXer Syndicated Linux News 0 05-30-2006 02:21 AM
gcc wont install, 'failed dependencies: glibc-devel is needed by gcc-3.3.3-41' TdlSnare SUSE / openSUSE 3 11-29-2004 02:13 PM
Kernel compiling: gcc-3.3 is 586, should be gcc-3.3 386 Erik Plaggenmar Linux - Software 0 10-01-2004 11:38 AM
export CC=/usr/bin/gcc-3.2 - switch gcc version? ferreter Linux - Software 1 08-20-2003 12:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration