Hello World project will not compile

2019-09-17 09:20发布

问题:

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:

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:

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.