Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install C++ plugin to Eclipse?

I have Eclipse Helios and wanted to code C++ using it, but I keep running into the "Launch failed. Binary Not found" error.

I installed the MingW C++ compiler using the "mingw-get-inst-20120426" file and selected the "C compiler, C++ compiler, MSYS Basic System, and MingW Developer Toolkit".

Then I went to Eclipse > project > properties > C/C++ General > Paths and Symbols, then selected the GNU C++ in the Includes tab and added the "C:\MinGW\lib\gcc\mingw32\4.6.2\include\c++" path.

I also went to C/C++ build > Environment and appended the "C:\MinGW\bin;C:\MinGW\msys\1.0\bin" to the PATH.

Then I created a Hello World C++ project, selecting the MingW GCC under Toolchains, and then built the project using the "hammer" icon.

However, once I ran the HelloWorld program it gets the "Launch failed. Binary Not Found" error.

Here is another error:

g++ -IC:\MinGW\lib\gcc\mingw32\4.6.2\include\c++ -O0 -g3 -Wall -c - 
fmessage-length=0 -osrc\HelloWorld.o ..\src\HelloWorld.cpp
Internal Builder: Cannot run program "g++": The system cannot find the 
file specified.

I also downloaded the CDT (C/C++ Development Tooling) and transferred the "features" and "plugins" folder to the eclipse folder.

Can someone please give me step-by-step on how to resolve this?

like image 479
user1631224 Avatar asked Aug 28 '12 19:08

user1631224


2 Answers

Firstly, in the following examples all drive-letters should be replaced with the relevant ones on your system. Not all of these steps are really necessary, but it works (and the more the merrier).

We start with the slightly simpler release config - we want to make it compile.

Go to Project -- Properties

Look if the include directories are correct and in place.

enter image description here

Go to Project -- Properties -- Run/Debug Settings -- NEW -- Main Tab

Set to Release and Browse to the Release folder of the project. If the exe file is not set type in its name.

Properties 1

Switch to Common Tab. Check Allocate Console and Launch in Background. Don't Run yet.

Properties 2

Go to Project -- Properties -- C/C++ Build -- Discovery Options

Tools -- GCC C++ Compiler

"Browse" to the mingw bin folder and select the g++.exe or copy mingw32-g++.exe to g++.exe

Note: The image points to mingw32-g++.exe please use g++.exe

Property 3

Right click on the project and look -- Build Configurations -- Set Active -- Release is checked.

Right click on the project -- Run As -- Run Configurations.

Under C/C++ Application select, the one which refers to the release version. Then click Run

If this works, I will show you how to set the Debug Properties. (more complicated)

like image 140
moskito-x Avatar answered Sep 30 '22 13:09

moskito-x


Nowadays (Eclipse Juno and newer), it is much simpler. You just need to:

  • Install MinGW (and including C++ compiler)
  • Add the paths "C:\minGW\bin" and "C:\minGW\msys\1.0\bin" (or wherever you installed MinGW to) to your Windows "Path" variable
  • Install Eclipse. If Eclise already is installed, restart it. it will recognize that MinGW is now available.
  • Create a New project: "C++ Project"
  • For every Project type in the following dialog, you should now be able to select the "MinGW GCC" toolchain
  • Happy coding
like image 42
RS1980 Avatar answered Sep 30 '22 12:09

RS1980