LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-07-2001, 08:02 AM   #1
ionic
LQ Newbie
 
Registered: May 2001
Posts: 6

Rep: Reputation: 0
Angry


Well i type the following into a file called hello.c

#include <stdio.h>
main()
{
printf("Hello\n");
return 0;
}

Then i use the gcc to compile it and it didn't run. During the compilation, it didn't prompt any error message. So i tot it work fine. But the problem now is it doesn't run at all. The output file is called a.out
 
Old 05-07-2001, 03:07 PM   #2
Damicles
LQ Newbie
 
Registered: Oct 2000
Location: Burlington/Whitewater, WI
Distribution: Slackware
Posts: 19

Rep: Reputation: 0
try:

gcc filename.c -o yourfilename

ie. gcc blah.c -o johns_pgm

now the executable file is called johns_pgm

Without the "-o" the compiler names the program "a.out"
 
Old 05-08-2001, 05:21 PM   #3
doodah
Member
 
Registered: Apr 2001
Location: Columbus,OH
Distribution: slackware
Posts: 122

Rep: Reputation: 15
cd to the dir that the source file is in, and then try to compile with this line-

$ gcc yourFileName.c -Wall -o FILENAME

the -Wall is to turn on all warnings, it is a good idea to compile with this in there so that your code is as clean as possible. the -o just specifies a file name to use for the binary file(after its compiled).

then still in your term, in the same dir as the binary file just type-

$ ./FILENAME

this should print

hello!

_peace
 
Old 05-10-2001, 08:59 AM   #4
ionic
LQ Newbie
 
Registered: May 2001
Posts: 6

Original Poster
Rep: Reputation: 0
Talking It works!

Yes it works! Why it must put ./Filename else it won't work. Izit i didn't set the path for my current directory? If so, then how to set?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
GCC Compiler rr_rr_29 Linux - Software 2 10-17-2005 04:14 AM
GCC compiler .. pashupathinath Programming 1 10-21-2004 12:20 PM
GCC Compiler HELP Otaking Linux - Newbie 5 04-08-2004 06:17 PM
GCC compiler? Forezt Linux - Newbie 2 11-23-2003 02:07 PM
GCC compiler...? ph0tik Linux - Newbie 4 04-22-2003 03:22 PM

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

All times are GMT -5. The time now is 04:00 PM.

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