LinuxQuestions.org
Help answer threads with 0 replies.
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 04-05-2004, 07:15 PM   #1
sdpeelejr
Member
 
Registered: Mar 2004
Location: South Carolina
Distribution: Fedora Core 1, Mandrake Linux 10.0
Posts: 51

Rep: Reputation: 15
Compiling C with Emacs


Okay, i'm trying to compile with emacs and here is my code
Code:
#include <stdio.h>
int main()
{
printf("Hello World!\n");
exit(0);
}
I go to Tools > Compile and at the bottom is this
Quote:
Compile: command -k
What I need to know is, what goes after the -k ?

Thanks


Last edited by sdpeelejr; 04-05-2004 at 07:17 PM.
 
Old 04-05-2004, 08:58 PM   #2
tomank
Member
 
Registered: Apr 2004
Distribution: rh9
Posts: 50

Rep: Reputation: 15
i do

gcc {options} sourcefilename.c
 
Old 04-05-2004, 09:05 PM   #3
sdpeelejr
Member
 
Registered: Mar 2004
Location: South Carolina
Distribution: Fedora Core 1, Mandrake Linux 10.0
Posts: 51

Original Poster
Rep: Reputation: 15
Okay, so I typed

Compile command: make -k gcc {options} hello.c

and it returned
Quote:
make -k gcc {options} hello.c
make: *** No rule to make target `gcc'.
make: *** No rule to make target `{options}'.
make: Nothing to be done for `hello.c'.

Compilation exited abnormally width code 2 at Mon Apr 5 22:02:18
What's wrong?

Sorry for being a newbie

Thanks
 
Old 04-05-2004, 09:21 PM   #4
tomank
Member
 
Registered: Apr 2004
Distribution: rh9
Posts: 50

Rep: Reputation: 15
either use make or gcc not both - i like gcc as a compiler so i use it

assuming your prog is called hello type

gcc hello.c

the {options} bit before is you can add options but if you dont kown what they do just leave them out!

else type

make -k hello.c

if it doesn't work you need to put the dir infront of the name of the file - when you opened emacs and started the buffer you typed C-x C-f to get a new buffer, just put the dir name in, ie

if i had hello.c in my /home/guest dir i would type (for gcc)

gcc /home/guest

i would then get a file called a.out in the same dir as the source file... to run the program just type

./a.out

when you are in the same dir as the file
 
Old 04-05-2004, 09:22 PM   #5
tomank
Member
 
Registered: Apr 2004
Distribution: rh9
Posts: 50

Rep: Reputation: 15
and just to add - i am a total newbie aswell, i've only had redhat for about 4 days - just stick with it

good luck
 
Old 04-07-2004, 08:13 AM   #6
sdpeelejr
Member
 
Registered: Mar 2004
Location: South Carolina
Distribution: Fedora Core 1, Mandrake Linux 10.0
Posts: 51

Original Poster
Rep: Reputation: 15
Okay, I typed Compile command: make -k hello.c and it goes
Quote:
cd /home/stevie
make: -k hello.c
make: Nothing to be done for `hello.c'.

Compilation finsished at Wed Apr 7 09:19:13
What am I doing wrong?

All I need is for this to compile into an executable so I can run the program.

Thanks!
 
Old 04-07-2004, 09:22 AM   #7
mfeat
Member
 
Registered: Aug 2003
Location: Akron, OH
Distribution: Fedora Core 3
Posts: 185

Rep: Reputation: 30
do make hello without the .c on the end
 
Old 04-07-2004, 10:07 AM   #8
sdpeelejr
Member
 
Registered: Mar 2004
Location: South Carolina
Distribution: Fedora Core 1, Mandrake Linux 10.0
Posts: 51

Original Poster
Rep: Reputation: 15
Compile command: make -k hello

returned

cd /home/stevie/
make -k hello
cc hello.c -o hello
make: cc: Command not found
make: *** [hello] Error 127

Compilation exited abnormally with code 2 at Wed Apr 7 11:04:50
 
Old 04-07-2004, 02:34 PM   #9
mfeat
Member
 
Registered: Aug 2003
Location: Akron, OH
Distribution: Fedora Core 3
Posts: 185

Rep: Reputation: 30
sounds like you don't have "cc" linked to "gcc", but that's another issue

just put in the following as is (no make -k)

gcc hello.c -o hello
 
Old 04-07-2004, 10:47 PM   #10
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
It's really worth learning to write makefiles so that you don't have to retype longer and longer gcc lines as you work on larger projects. here's a little tutorial that babies you through it:

http://www.eng.hawaii.edu/Tutor/Make/

The OP might want to check that he does have gcc installed: I thought it was pretty standard for gcc packages to link cc to gcc for you.
 
  


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
programming c++ in emacs , compiling NL-Stitch General 11 01-27-2005 06:41 PM
compiling in emacs blacbastard Programming 7 07-03-2003 11:10 PM
compiling in emacs blacbastard Linux - Software 1 07-02-2003 08:59 PM
Compiling in emacs blacbastard Linux - Software 0 07-02-2003 06:53 AM
Compiling emacs aizkorri Programming 2 03-16-2002 07:24 AM


All times are GMT -5. The time now is 11:52 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration