Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compilator en windows

9 views
Skip to first unread message

Jose Cristino Cepeda Uceta

unread,
Sep 19, 2012, 7:50:47 AM9/19/12
to help-gn...@gnu.org

i am new to emacs. I install emacs on windows and I want to configure it to work with the MinGW compiler but not how

Pascal J. Bourguignon

unread,
Sep 19, 2012, 12:15:59 PM9/19/12
to
Jose Cristino Cepeda Uceta <crist...@hotmail.com> writes:

> i am new to emacs. I install emacs on windows and I want to configure
> it to work with the MinGW compiler but not how

Compiling from emacs, is usually done with M-x compile RET
By default, it runs the make command.

So you'd write a Makefile with rules to call the MinGW compiler.

Writing Makefile doesn't concern emacs (emacs just provides an editing
mode for Makefiles, with nice colorization). So read the documentation of
your make program.

Calling the MinGW compiler doesn't concern emacs (emacs just provides a
compile mode to launch a compiler, and to analyse error messages). So
read the documentation of your MinGW compiler.


I know the usual unix or GNU make, but often on MS-Windows people use
another make, with I guess a different syntax. The principle would be
the same. On unix you'd write a Makefile like this:

----(Makefile)----------------------------------------------------------

# variables: specific to the compilation of a specific program

EXE=mypgm
OBJ=mymodule.o mypgm.o
INCS=-I.
LIBS=-lm

# CC is usually predefined by make; but you can also define it to point
# to a specific compiler; you'd put the path to the MinGW compiler here.

CC=gcc


# rules: always about the same.

all:$(EXE)

$(EXE):$(OBJ)
$(CC) -o $@ $< $(LIBS)

.o.c: ; $(CC) -c $(INCS) -o $@ $<

# dependencies: depend on the specific program; can also be generated
# automatically from the sources.

mymodule.o : mymodule.h mymodule.c
mypgm.o : mymodule.h mypgm.c

------------------------------------------------------------------------


If you have a simple single source file program, you can also often
compile it just calling the compiler, without a Makefile. Then you can
edit the command line proposed by M-x compile to call directly the
compiler:


M-x compile RET C-a C-k gcc -o mypgm *.c -lm RET
^^^^^^^^^^^^^^^^^^^^

Having read the documentation of the MinGW compiler, you would
substitute the part underlined by "^^^^" with the right MinGW compiler
invocation.

--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.

Eli Zaretskii

unread,
Sep 19, 2012, 12:36:09 PM9/19/12
to help-gn...@gnu.org
> From: Jose Cristino Cepeda Uceta <crist...@hotmail.com>
> Date: Wed, 19 Sep 2012 07:50:47 -0400
>
> i am new to emacs. I install emacs on windows and I want to configure it to work with the MinGW compiler but not how

No configuration required. If you have MinGW installed, type
"M-x compile" followed by the command you'd type at the shell prompt
to compile your program. For example:

M-x compile RET

Emacs will show:

Compile command: make -k

If you don't have a Makefile, delete "make -k" and type the GCC
command like "gcc hello.c -o hello.exe" and hit RET.

0 new messages