Richard
Richard

Reputation: 948

Problems building projects with Eclipse CDT (Luna)

I've just recently installed the eclipse CDT 8.5 Luna via the "Install software..." repository feature and the MinGW toolkit for C++.

When I try creating a new C++ project, choosing an "Empty Project" from "Executable" then building it yields a "Launch failed. Binary not found." After consulting multiple forums, I've managed to set the Makerfile Project's Binary Parsers default to "PE Windows Parser" via Windows >> Preferences >> C/C++ >> New C/C++ Project Wizard >> Makefile Project. When I try building the project, it still gives me the same error.

I've tried creating a "Hello World C++ Project" instead from "Executable", and after building, the binaries folder miraculously builds itself.

Why does "binaries" only build when I create a "Hello World C++ Project" and not when I build an "Empty Project"?

Another thing is that when I try running the default Hello World main.cpp code, nothing seems to output in the console. Again I've consulted various forums and the only solution to this issue is right clicking my project in Project Explorer >> Properties >> Run/Debug Settings >> Edit... [HelloWorld.exe] >> Environment >> New... >> and creating Variable PATH; Value C:\MinGW\bin.

Is there a way to get the output to work in console without having to manually set the environment for new projects? It just seems convoluted to have to go through all these steps.

Upvotes: 0

Views: 295

Answers (2)

Yousef
Yousef

Reputation: 1

It maybe late for the answer, but anyway it may helps you or the others.

I faced the same problem and checked so many forums but the solution I've found is very very simple;

after you made your empty project and then your source file and then after you finished typing your codes in the source file JUST MAKE SURE OF THIS:

click FILE>SAVE.

I did this and worked for me if you got any problem let me now.

Upvotes: 0

NineToeNerd
NineToeNerd

Reputation: 327

According to help.eclipse.org, for an empty project you have to create your own makefile.

Quoted text from the website:

Creating a makefile

For the purpose of this tutorial, you were instructed to create a C++ Project which requires you to create a makefile.

To create a makefile:

In the Project Explorer view, right-click the HelloWorld project folder and select New > File.

In the File name box, type makefile.

Click Finish.

Type the gnu make instructions below in the editor. Lines are indented with tab characters, not with spaces.

all: hello.exe

clean:

--TAB-- rm main.o hello.exe

hello.exe: main.o

--TAB-- g++ -g -o hello main.o

main.o:

--TAB-- g++ -c -g main.cpp

Click File > Save.

Your new makefile, along with your main.cpp file are displayed in the Project Explorer view. Your project now contains main.cpp and makefile. You can now build your HelloWorld project

This fixed that same issue for me.

Note: Of course, you need to change main.cpp to the name of your source file, if you used a different name.

Edit:

You can also have a makefile automatically generated by right-clicking your project and going to Preferences->Build Settings. If you have an automatically generated makefile, you must change the build settings to include all compiler flags.

Upvotes: 0

Related Questions