* Newbie - Can't compile and run C program
@ 2012-03-18 18:16 taariqq
2012-03-18 20:21 ` Peter Dyballa
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: taariqq @ 2012-03-18 18:16 UTC (permalink / raw)
To: Help-gnu-emacs
Hi all,
Was looking for some help and google sent me to you guys. Hope I am not
intruding.
I've just downloaded emacs 23.4 for my winxp machine. To go into C mode by
typing M-x c-mode. I type the typical hello world program. I type M-x
compile to compile the program ... and this is where I am stuck. It is not
generating a.out. Either it gives me an error if I use make -k, or if I
compile w/o make command, it pops the program open in another window.
I have used emacs in the the past to compile and run C programs
successfully, but I am forgetting something or else.
Greatly appreciate it.
--
View this message in context: http://old.nabble.com/Newbie---Can%27t-compile-and-run-C-program-tp33527190p33527190.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Newbie - Can't compile and run C program
2012-03-18 18:16 Newbie - Can't compile and run C program taariqq
@ 2012-03-18 20:21 ` Peter Dyballa
2012-03-18 21:11 ` taariqq
2012-03-18 21:39 ` Lars Ljung
2012-03-18 22:08 ` taariqq
2 siblings, 1 reply; 9+ messages in thread
From: Peter Dyballa @ 2012-03-18 20:21 UTC (permalink / raw)
To: taariqq; +Cc: Help-gnu-emacs
Am 18.3.2012 um 19:16 schrieb taariqq:
> I am forgetting something or else
This seems to be a correct observation...
GNU Emacs' compile-mode by default uses make to produce a programme. When you want to compile a single file you can write a Makefile for it – or you substitute the default compile command (make -k) with a compiler invocation line. The best is when you invoke M-x compile RET from the window with source file – then the compilation will run in the same directory where the source file is. Of course a new window opens, named *compilation*. Maybe you can customise this behaviour if you don't like it... (Of course compilation mode allows you to run your programme in it.)
--
Greetings
Pete
Work is the curse of the drinking class.
– Oscar Wilde
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Newbie - Can't compile and run C program
2012-03-18 20:21 ` Peter Dyballa
@ 2012-03-18 21:11 ` taariqq
2012-03-18 21:57 ` Peter Dyballa
2012-03-18 21:58 ` Christopher Schmidt
0 siblings, 2 replies; 9+ messages in thread
From: taariqq @ 2012-03-18 21:11 UTC (permalink / raw)
To: Help-gnu-emacs
Peter, I greatly appreciate your taking the time to respond. When I do
M-x compile RET hello.c RET
the window that opens is not compilation or anything. It is a new instance
of emacs that opens up (I have .c files associated with emacs) with the
same code for hello.c displayed in it. There seems to be window flashing by
just before that, but that is all
Peter Dyballa wrote:
>
>
> Am 18.3.2012 um 19:16 schrieb taariqq:
>
>> I am forgetting something or else
>
> This seems to be a correct observation...
>
> GNU Emacs' compile-mode by default uses make to produce a programme. When
> you want to compile a single file you can write a Makefile for it – or you
> substitute the default compile command (make -k) with a compiler
> invocation line. The best is when you invoke M-x compile RET from the
> window with source file – then the compilation will run in the same
> directory where the source file is. Of course a new window opens, named
> *compilation*. Maybe you can customise this behaviour if you don't like
> it... (Of course compilation mode allows you to run your programme in it.)
>
> --
> Greetings
>
> Pete
>
> Work is the curse of the drinking class.
> – Oscar Wilde
>
>
>
>
--
View this message in context: http://old.nabble.com/Newbie---Can%27t-compile-and-run-C-program-tp33527190p33527884.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Newbie - Can't compile and run C program
2012-03-18 18:16 Newbie - Can't compile and run C program taariqq
2012-03-18 20:21 ` Peter Dyballa
@ 2012-03-18 21:39 ` Lars Ljung
2012-03-18 22:08 ` taariqq
2 siblings, 0 replies; 9+ messages in thread
From: Lars Ljung @ 2012-03-18 21:39 UTC (permalink / raw)
To: help-gnu-emacs
taariqq <taariqq@gmail.com> writes:
> I've just downloaded emacs 23.4 for my winxp machine. To go into C mode by
> typing M-x c-mode. I type the typical hello world program. I type M-x
> compile to compile the program ... and this is where I am stuck. It is not
> generating a.out. Either it gives me an error if I use make -k, or if I
What C compiler have you installed?
MinGW (http://www.mingw.org/) probably works well together with Emacs
and M-x compile. It includes GCC, GNU make, and a bunch of other useful
stuff.
--
Lars Ljung
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Newbie - Can't compile and run C program
2012-03-18 21:11 ` taariqq
@ 2012-03-18 21:57 ` Peter Dyballa
2012-03-18 21:58 ` Christopher Schmidt
1 sibling, 0 replies; 9+ messages in thread
From: Peter Dyballa @ 2012-03-18 21:57 UTC (permalink / raw)
To: taariqq; +Cc: Help-gnu-emacs
Am 18.3.2012 um 22:11 schrieb taariqq:
> When I do
> M-x compile RET hello.c RET
> the window that opens is not compilation or anything. It is a new instance
> of emacs that opens up (I have .c files associated with emacs) with the
> same code for hello.c displayed in it.
Because you're obviously running MS Losedos and since you do perform a compile action "apply C source file" a new instance of GNU Emacs is created to fulfil this.
As I wrote: don't "hello.c" something but compile it! At least me, I do not know of a C compiler named "hello.c". And this compiler seems to extremely clever, knowing which file to compile, how to compile it (32-bit/64-bit, object file, shared or static library, or executable).
To be more precise: I would M-x compile RET gcc -I/opt/local/include -L/opt/local/lib -fconstant-cfstrings -DHAVE_CONFIG_H -I. -I../src -I.../emacs-23.4-mac-2.0/lib-src -I.../emacs-23.4-mac-2.0/lib-src/../src -Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t -v -g -H -pipe -fPIC -fno-common -Os -m64 -march=core2 -mtune=core2 -fomit-frame-pointer -msse4.2 .../emacs-23.4-mac-2.0/lib-src/digest-doc.c -o digest-doc RET
--
Greetings
Pete
If we don't succeed, we run the risk of failure.
– George W. Bush
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Newbie - Can't compile and run C program
2012-03-18 21:11 ` taariqq
2012-03-18 21:57 ` Peter Dyballa
@ 2012-03-18 21:58 ` Christopher Schmidt
2012-03-18 22:05 ` taariqq
2012-03-18 22:32 ` taariqq
1 sibling, 2 replies; 9+ messages in thread
From: Christopher Schmidt @ 2012-03-18 21:58 UTC (permalink / raw)
To: help-gnu-emacs
taariqq <taariqq@gmail.com> writes:
> Peter, I greatly appreciate your taking the time to respond. When I do
> M-x compile RET hello.c RET the window that opens is not compilation
> or anything. It is a new instance of emacs that opens up (I have .c
> files associated with emacs) with the same code for hello.c displayed
> in it. There seems to be window flashing by just before that, but that
> is all
M-x compile RET asks you for the compile command. For starters, try M-x
compile RET gcc hello.c RET.
Christopher
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Newbie - Can't compile and run C program
2012-03-18 21:58 ` Christopher Schmidt
@ 2012-03-18 22:05 ` taariqq
2012-03-18 22:32 ` taariqq
1 sibling, 0 replies; 9+ messages in thread
From: taariqq @ 2012-03-18 22:05 UTC (permalink / raw)
To: Help-gnu-emacs
Hi Chris,
M-x compile ... brings 'Compile commant:' prompt ... upon typing
gcc hello.c RET ... it says gcc is not recognized as an external or internal
command, operable program or batch file
Compilation exited abnormally
Christopher Schmidt-6 wrote:
>
> taariqq <taariqq@gmail.com> writes:
>
>> Peter, I greatly appreciate your taking the time to respond. When I do
>> M-x compile RET hello.c RET the window that opens is not compilation
>> or anything. It is a new instance of emacs that opens up (I have .c
>> files associated with emacs) with the same code for hello.c displayed
>> in it. There seems to be window flashing by just before that, but that
>> is all
>
> M-x compile RET asks you for the compile command. For starters, try M-x
> compile RET gcc hello.c RET.
>
> Christopher
>
>
>
--
View this message in context: http://old.nabble.com/Newbie---Can%27t-compile-and-run-C-program-tp33527190p33528131.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Newbie - Can't compile and run C program
2012-03-18 18:16 Newbie - Can't compile and run C program taariqq
2012-03-18 20:21 ` Peter Dyballa
2012-03-18 21:39 ` Lars Ljung
@ 2012-03-18 22:08 ` taariqq
2 siblings, 0 replies; 9+ messages in thread
From: taariqq @ 2012-03-18 22:08 UTC (permalink / raw)
To: Help-gnu-emacs
What command was it, to keep the window open and waiting for input before
being closed, so one could see the output of simple programs like hello
world?
I see cin.get(); being mentioned for C++, but I can't locate the one for C
taariqq wrote:
>
> Hi all,
>
> Was looking for some help and google sent me to you guys. Hope I am not
> intruding.
> I've just downloaded emacs 23.4 for my winxp machine. To go into C mode by
> typing M-x c-mode. I type the typical hello world program. I type M-x
> compile to compile the program ... and this is where I am stuck. It is not
> generating a.out. Either it gives me an error if I use make -k, or if I
> compile w/o make command, it pops the program open in another window.
>
> I have used emacs in the the past to compile and run C programs
> successfully, but I am forgetting something or else.
>
> Greatly appreciate it.
>
--
View this message in context: http://old.nabble.com/Newbie---Can%27t-compile-and-run-C-program-tp33527190p33528142.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Newbie - Can't compile and run C program
2012-03-18 21:58 ` Christopher Schmidt
2012-03-18 22:05 ` taariqq
@ 2012-03-18 22:32 ` taariqq
1 sibling, 0 replies; 9+ messages in thread
From: taariqq @ 2012-03-18 22:32 UTC (permalink / raw)
To: Help-gnu-emacs
Chris,
I have also downloaded Cygwin with emacs ... I gave the command to it and it
seems to have worked ... it says 'compilation finished' ....
Now what do I do? :)
M-x compile RET asks you for the compile command. For starters, try M-x
compile RET gcc hello.c RET.
Christopher
--
View this message in context: http://old.nabble.com/Newbie---Can%27t-compile-and-run-C-program-tp33527190p33528234.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-03-18 22:32 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-18 18:16 Newbie - Can't compile and run C program taariqq
2012-03-18 20:21 ` Peter Dyballa
2012-03-18 21:11 ` taariqq
2012-03-18 21:57 ` Peter Dyballa
2012-03-18 21:58 ` Christopher Schmidt
2012-03-18 22:05 ` taariqq
2012-03-18 22:32 ` taariqq
2012-03-18 21:39 ` Lars Ljung
2012-03-18 22:08 ` taariqq
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).