Q:

how to make eclipse build the right target when trying to run an executable

I have a c++ project in eclipse and two targets in Makefile, say t1 and t2. t1 appear as the first target in Makefile so is the default. The problem is when I try to run t2.o, eclipse automatically make the default target t1 and then execute t2. I am asking is there anyway to configure eclipse so that it can make t2.o before executing it... thanks in advance.

A:

(first a question : by 'execute t2.o', don't you mean 'execute t2' ?)
1/ your makefile may need a line like this :
all: t1 t2  
.PHONY: all  

2/ you could also re-create your project as a 'Managed make c++ project' and create one build configuration per target, Eclipse will manage dependencies.

