0
votes

I recently started using Eclipse CDT for developing C++ applications. I downloaded the Eclpse Kepler CDT bundle, and it opened up properly, but when i created a simple hello world application I was getting an error"Binary Not Found", even after building the project.

Ill show you what my console display

19:54:11 **** Incremental Build of configuration Debug for project HelloWorld ****
make all 
Building file: ../src/HelloWorld.cpp
Invoking: GCC C++ Compiler

g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/HelloWorld.d"-MT"src/HelloWorld.d" -o "src/HelloWorld.o" "../src/HelloWorld.cpp"

cc1plus: error: to generate dependencies you must specify either -M or -MM
make: *** [src/HelloWorld.o] Error 1

19:54:11 Build Finished (took 106ms)

I tried running the program with 2 toolchains Cross GCC and Linux GCC.

Could someone please tell me whats going wrong?

1
What compiler versions are you using? And can you add the contents of your makefile to the question? As given, the instruction to compile your file seems to work fine with MinGW w64 4.9.1 as well as g++ 4.7.3. As a sidenote, there seems to be a space missing between the -MF and the -MT tags, but that does not appear to be the reason for your error. - Bart van Nierop
My compiler version is 4.5.1. The make file is the standard one generated by eclipse by default. Could you please tell me how to add the -M or -MM option, to eclipse;s building argument?? Thanks - Mona P
As far as I'm aware, you shouldn't have to. -MMD should be perfectly fine. I haven't used Eclipse for quite some time because I'm sadistic and prefer making my own Makefiles. However, to add a command-line option, you can go to Project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> Compiler -> Miscellaneous and add -M or -MM to Other flags. See this screenshot. - Bart van Nierop
The code compiled and ran perfectly once I add the argument under the preferences of the project:) - Mona P
Glad it helped. Added as an answer for the next person who runs into the same problem. Also now I can kill the link to the screenshot when cleaning up some time in the future without messing up. - Bart van Nierop

1 Answers

0
votes

Tested with a bunch of different compilers, the command as given in the OP appears to work just fine. This seems to be a case of the real world being different from what should be.

The solution is to do what the compiler tells us to do, which is to add the -M or -MM flag.

To do that, head to Project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> Compiler -> Miscellaneous and add -M or -MM to Other flags.

The picture below illustrates this:

Screenshot of settings in Eclipse.

As a side note, there is a missing space between the -MF flag and the -MT flag, but this does not appear to be the cause of the problem.