Hello World project will not compile

狂风中的少年 提交于 2020-01-06 08:51:10

问题


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.



来源:https://stackoverflow.com/questions/26203032/hello-world-project-will-not-compile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!