Compiling C with Emacs
Okay, i'm trying to compile with emacs and here is my code
Code:
#include <stdio.h> Quote:
Thanks :newbie: |
i do
gcc {options} sourcefilename.c |
Okay, so I typed
Compile command: make -k gcc {options} hello.c and it returned Quote:
Sorry for being a newbie:newbie: Thanks |
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 |
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 |
Okay, I typed Compile command: make -k hello.c and it goes
Quote:
All I need is for this to compile into an executable so I can run the program. Thanks! |
do make hello without the .c on the end
|
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 :cry: |
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 |
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. |
All times are GMT -5. The time now is 04:51 PM. |