Revised answer: If you want to avoid writing a real makefile, you can write something like this:
all:
gcc *.c -o runme.exe
You need to specify the binary which gcc outputs (gcc [..] -o <this one>
) in the run settings (in the previous example, it should point to runme.exe
). Go to Run
->Run Configurations
, and under C/C++ Application
browse and look for runme.exe
.
I would, however, strongly advise you to seriously learn about makefile. The beauty of makefiles is that you can use very little features at first and use more and more as you go on (as you saw, writing a "dummy" file was very quick). At first I suggest you write something a bit more "clever" than what I gave you above. Here's a nice tutorial and an example:
all: hello
hello: main.o factorial.o hello.o
g++ main.o factorial.o hello.o -o hello
main.o: main.cpp
g++ -c main.cpp
factorial.o: factorial.cpp
g++ -c factorial.cpp
hello.o: hello.cpp
g++ -c hello.cpp
clean:
rm -rf *o hello
all is what compiles at default. What comes before the :
are rule names and after it are the dependencies. i.e, to compile all
you need to compile hello
(though only if it's been updated), and so forth. the line below the rule is the command to compile. I hope this helps. Please read the tutorial, Makefiles are important.