tags:

views:

130

answers:

3

Hi,

I have install the C/C++ CDT Version of Eclipse. After making a HelloWorld.c file and get the code in there I get an error of "Launch failed. Binary not found".

I found in google that my Eclipse miss the compiler and I install MinGW on my computer and add the path to env variables (tested it with "gcc -v" in cmd and succeded).

1) I can build now, but have no idea how to make a MAKEFILE. - I Read 10 tutorials but don't understand it - ideas?

2) I can build, but not run, I get "Launch failed. Binary not found" - ideas?


Found the error: I never maked a ".c" file -.- after renaming it - works fine.

+3  A: 
  1. Revised answer: If you want to avoid writing a real makefile, you can write something like this:

    all:
        gcc *.c -o runme.exe
    
  2. 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.

Amir Rachum
1) how? 2) don't get it, please be gentle with a beginner
Kovu
@Amir Rachum: Learning about makefiles is always a good idea, but usually Eclipse writes the makefile for you.
Philipp
@Philipp IMHO, when the project is big enough, Eclipse's makefile management may not be enough.
Amir Rachum
+1  A: 

Add the directory that gcc resides in (C:\MinGW\bin or whatever) to your PATH environment variable and restart Eclipse (important!). This is the process in XP: http://vlaurie.com/computers2/Articles/environment.htm. That should sort it out.

Chris Dennett
Done allready, it builds over MinGW, but execute dont work
Kovu
+1  A: 

1 I suggest you to take a look at this:

http://www-scf.usc.edu/~csci410/handouts/make.pdf

It's a basic gmake tutorial and should be enough to get you started. But right now, for single file project, I suggest you to just skip creating Makefiles and doing in the command prompt:

gcc -o helloworld.exe helloworld.c

And running your executable in the prompt. You can worry about Makefiles later in your learning curve.

2 How did you setup your project?

Vitor Py
1) Thanks - where I can find a command prompt in eclipse, i didnt find it.2) make C Project -> make C source code -> main-method with printf() -> build
Kovu