Eclipse Luna With MinGW: "Launch failed. Binary not found." - c++

I have searched all over the web and have tried everything I could to fix this problem, to no avail. So here I am making a new post, hoping to fix this terribly frustrating problem.
I have the Eclipse IDE for C/C++ Developers that on my Windows 7 computer. The version of Eclipse is Luna Service Release 2 (4.4.2) and the build ID is 20150219-0600.
I have MinGW installed onto my computer, and I downloaded all the package choices just to be safe.
I create a C++ project. The "Project type" is Executable > Empty Project and the "Toolchains" is "Cross GCC".
I select both "Debug" and "Release" in the "Configurations".
I leave the "Cross compiler prefix" blank because I don't know what to write. I then put in "F:\MinGW" as the "Cross compiler path".
I create a new source file in the project and write the infamous Hello World program (in C++, of course). When I save the project, it gives me two errors in the "Problems" tab:
Program "g++" not found in PATH
Program "gcc" not found in PATH
When I build the project, it adds on another error:
Program "make" not found in PATH
I go to Project > Properties > C/C++ Build > Tool Chain Editor and change the "Current builder" from "Gnu Make Builder" to "CDT Internal Builder".
The error Program "make" not found in PATH then disappears.
I go to Window > Preferences > C/C++ > New C/C++ Project Wizard > Makefile Project and set the "Binary parser" to "PE Windows Parser". I clear the project, save the project, and build the project, but the 2 errors remain.
If I go to Project > Properties > C/C++ Build > Environment and set the value of the "PATH" variable to "F:\MinGW\bin", still nothing happens and the two errors remain.
Now, when I attempt to run the project (ctrl + F11), it spits out the error Launch Failed. Binary not found.
In the "Project Explorer", I see a HelloWorld file that contains an "Includes" file (containing the compiler libraries?), a "Debug" folder (containing a HelloWorld.exe and a main.o), and a main.cpp file (containing my Hello World program).
Thank you in advance for taking the time to read this and for trying to help.

You need to update environment variable PATH. Check this page.
You must add C:\MinGW\bin; to your user PATH environment variable manually.

I suggest, not a solution, at least you want to make sure the following.
Recheck that the PATH is set up right. Sometime we think we did, but the computer does not. In the command line, type the following command to see the gcc installed right and PATH is set right.
gcc --version
echo $PATH
or
echo %PATH%
All things are right as you did above, but it does not work?, Then remove and reinstall mingw and eclipse CDT cleanly. Don't change and keep the default options in the Eclipse CDT. Without any option changes CDT, it should work NOWADAYS. Eclipse CDT(8.7, 8.8) is pretty much stable.
Blessings,
(a debtor)<><

Related

Eclipse: Nothing to build for file

I did look up on the Internet to find the solution for my problems, unfortunately all advices didn't seem to help so perhaps you will be more helpful in my case.
I did set up my Eclipse IDE with MinGW,
I did set up my Windows' environment variables right, for example:
added C:\Program Files\eclipse; C:\MinGW\bin;C:\MinGW\msys\1.0\bin
and somehow managed to create project with .cpp file that actually worked, at the beggining I build this file and than run it with these simple icons. Somehow, it compiled without errors and output the right results.
I hoped that it would remain perfect for eternity, but somehow today while dealing with new c++ project I have encountered the following problems.
I build new C++ project, by clicking:
File -> New -> C++ Project -> marking executable project Hello World Project -> by default I set up to use MinGW toolchain (nothing has changed since the moment it worked perfectly smooth) -> name project and start work.
Building project looks ok, I get no errors whatsover. But when I try to run it the console window is completely blank - with popping info: Nothing to build for [project name].
I really hope that once I've made some project actually work all changes will remain untouched and that I will not have to fiddle around once again with all these settings.
I did not change anything at all and now it doesn't work...
Right click on project -> Properties -> C/C++ Build -> Environment -> all variables are set.
Toolchain set to MinGW which has worked so well.
And yet I can't run this executable program, this IDE is really starting to drive me crazy.
Any idea what might have happened over the last magical six hours when suddenly Eclipse refuse to work properly again ?
Try to right click the eclipse project and click refresh. An item should appear under executables. If an item appears you should be able to run it from inside eclipse (not sure how though, maybe by double clicking or from the right click menu) or by using the command promt. To run it through the command prompt, using cd command browse to the folder where the executable file resides (somewhere inside the project folder inside your workspace folder) and run it by typing the name of the executable (fx hello.exe or just hello).

"Unresolved include" errors in c++

I'm a new C++ programmer using Eclipse. Eclipse seems to recognize C++: It let me create a new C++ project and understands the syntax. However, whenever I try to #include anything, I get an "Unresolved include" error.
I have CDT installed. I also just installed MinGW and MySys and set the path variables correctly.
It looks like something's still missing from Eclipse though -- when I right click on my project and go to "properties -> C/C++ build -> Settings" all I can access are the "binary parsers" and "error parsers" tabs. The window should look like this...
...but I can't see the tool settings, build steps or build artifact tabs.
That's all my research has turned up so far. What should I do next?
Settings on screenshot related to build process. For correct work editor (autocomlete, includes) you need to set same dirs in the C/C++ General/Paths and symbols, includes, GNU C++. Also, if path variable containt dir with g++ ecplise should to have prepared configuration if you choose mingw toolchain while creating project.
Update for comment

Eclipse indexing not working

I am using CDT in Eclipse 3.5.2 Galileo in Ubuntu.
My eclipse's indexer doesn't work at times. By that I mean when I ctrl click a function it says Could not find symbol in index. Also, F3 button click results in the same error message. Actually most of the places it is not working and works in very few places.
I have seen some other versions of Eclipse where under File menu a menu item listed for Indexing. Like File->Indexer->Rebuild.... But in my File menu there is no such menu item for the Indexer.
Will the only way be to use some other release of Eclipse or am missing something? Any pointers regarding this would be helpful.
In my case nothing has worked and at last I did the following:
1) Close the project
2) Delete the project(do not check from disk option)
3) create new project with existing code(use the deleted project path)
4) Successfully indexed my c++ code
To add paths containing code to parse, follow these steps :
1. Right click on the project
2. Select Properties
3. Go to C/C++ General
4. Go to Path and Symbols
5. If the paths are missing, add paths.
To re-parse the code follow these steps :
1. Right click on the project
2. Select Index
3. Rebuild
If this doesn't work, then you are out of luck. c++ is very difficult language to parse.
If your indexer is stuck and it hangs for infinite time, you can delete the indexer related files of your project from .metadata. Make sure eclipse is not running in the meanwhile.
The .metadata directory is located as a hidden folder in the path of your workspace.
There you can navigate to:
<workspace_path>/.metadata/.plugins/org.eclipse.core.runtime/.settings/
Inside the .settings/ directory there are .prefs files which store the preferences of each project individually.
For example: org.eclipse.cdt.core.prj-test-project.prefs stores the preferences of the project test-project
Open this file with the text editor and remove all the lines starting with indexer. This will reset the indexer settings for this specific project to the default.
Alternatively, you can remove all the lines starting with indexer from org.eclipse.cdt.core.prefs; doing this will reset the indexer settings for the whole workspace.
I believe you can clear the index by running:
rm .metadata/.plugins/org.eclipse.jdt.core/*.index
And then restarting Eclipse. It will then rebuild its index.
This worked for me in a Java project, but I imagine its the same index for all (most?) project types.
Right click on the project.
Select New->Convert to a C++ Project.
Select your configuration. And then Next
Indexer will start indexing all the files.
For me this worked:
Right click and close the project
Open the project again
Right click and select Index->Rebuild
I hope it helps anybody.
You can try rebuilding the index.
Right-click on the project in Project View. Then Index -> Rebuild.
Here is the solution I used after Project->C++ Index->Rebuild failed. This trick avoid deleting your current project :
1) Copy the current project (Right click->Copy from Project Explorer)
2) Paste it (Right click->Paste from Project Explorer) and give the copy another name
3) The indexer should now start and index both projects
4) When indexation is complete, you can delete the copy
PS: Make sure your original project is an actual C++ Project or this will obviously not work.
Convert a project to C or C++ nature:
Right click on project: New >  Convert to C/C++ Project
In "Convert to C or C++": Choose C/C++ Project
In "Project options": Check "Specify Project Type"
...Project Type: Choose "Makefile project"
...Toolchains: Gross GCC
I was having the same problem and it turns out that the index folder was owned by root (I must have run Eclipse as a root once for some reason) I reclaimed the project folder using sudo chown -R username projectfolderpath and problem solved.
Execute eclipse.exe -clean -refresh where the eclipse is installed.
Create a new C/C++ Project in Eclipse with Given Source code folder path. (Not with New Project based on existing workspace)
Above steps worked for me.
For me it was issue that when creating a project indexer was chosen as none. Deleted the project and while creating the project again I chose the indexer options as per my need "LINUX_GCC", then it worked for me
Just came across the same problem in my C++ ARM Cross GCC project. I'm developing on Windows, using Makefile and an Ubuntu Docker image with GNU ARM Embedded Toolchain to build the project.
The solution to get rid of the unresolved symbols, in my case, could be divided into two parts:
The CDT Arm Cross GCC Built-in Compiler Settings didn't have the path to the compiler.
In the Project Properties -> C/C++ General -> Preprocessor Include Paths -> Providers(tab) the path to the compiler must be provided.
Using the GNU ARM Embedded Toolchain, the entry for the Command to get compiler specs: I currently use is:
C:\GNU_Arm_Embedded_Toolchain\9-2020-q2-update\bin\arm-none-eabi-g++.exe ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"
Note: Yes, I am having installed the same toolchain on my Windows machine as I'm using in the Docker image.
To verify, that the call is correct, you can tick the Allocate console in the Console View, which will provide hlepful output to the Console. Also, in the Entries tab, when you unroll the CDT Arm Cross GCC Built-in Compiler Settings you should see the includes and symbols included.
Missing symbol in the Project Properties -> C/C++ General -> Paths and Symbols menu.
As I have my defines in the Makefile, I forgot to add the define of my MCU also here.
Hope this helps to someone! :)
For the most part, the other answers tackle the situation wherein one "had" a working index earlier and things have gone astray for some reason.
On the other hand, I faced a problem wherein I needed to install everything from scratch (eclipse, workspace, c++ project etc.) and the indexing just wouldn't work. I finally found the solution here: https://www.eclipse.org/forums/index.php/t/1109004/
The key inputs from the above page are:
You need to setup include paths for the Indexer just as you would need
to for the compiler. The Indexer and compiler are completely independent.
The Indexer include paths are set by
Project -->Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. --> Entries tab --> CDT UserSettings Entries ...
and
You could try using
Project --> Properties --> C/C++ General --> Paths and Symbols
That's supposed to merge telling the compiler and Indexer
in one place.
However, this latter part of the suggestion did not work for me.

Trouble compiling using Eclipse CDT with alternate toolchain

I'm trying to use Eclipse CDT (Version: Indigo Service Release 1 Build id: 20110916-0149) to build and debug my c/c++ project in RHEL6 64 bit Linux, and I'm having issues. I've done what I thought was necessary to use an alternate toolchain to perform the compilation, but something seems to be missing, as eclipse says that it compiled the source, but it didn't really do it.
For the setup I went to C/C++ Project Properties -> C/C++ Build configuring the "Debug" configuration, on the "Builder Settings" tab I unchecked the "Use default build command" checkbox, and entered the name of my toolchain "mk all" into the "Build command" field. I then unchecked the "Generate Makefiles automatically" checkbox. Next I changed the "Build Directory" field to be "". Lastly I went to the "Behavior" tab and unchecked the "Build on resource save (Auto build)" checkbox and changed the "make build target" to be "all ${selected_resource_loc}" .
Now, when I go to my project, and select a subdirectory that needs to be built, and then click on the build button on the toolbar this is what happens:
1) I see the "Build Project..." in the progress window briefly
2) The CDT build console displays this:
**** Build of configuration Debug for project myproj ****
mk all
**** Build Finished ****
The above is what I see when my code needs rebuilt, does not need rebuilt, and when there are errors in the compilation. I can verify this by opening a bash terminal and typing "mk" in the directory I want to build. When I compile from the terminal, I can see the compiler output (success and errors etc..), but eclipse shows me nothing of the sorts.
I must be missing something, but I'm not sure what. Does anyone have any ideas of what I'm doing wrong?
--update--
I found out what part of my issue was, which turned out to be that my build tool was invoked via a bash script without a shebang at the top.
My next issue is that the build is always invoked from the root of the project, which has no makefile. I have tried putting the "${selected_resource_loc}" variable into both the "make build target" field, but it does not seem to have the correct effect as my "mk all" command seems to be invoked with the variable being translated to an empty string every time. Any ideas on this side issue?
'DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far ...'
I sorta solved my issue. I had asked a friend with a similar setup to try this out, and he got it to work on the first try. I then concluded that it was either my install or my project. Thus, I proceeded to delete the project files (.project and .cproject) and recreate the project. After I completed that, it seemed to work like a charm. I must have selected an obscure incompatible project option, that caused something to not expand the ${selected_resource_loc} variable. Weird. I hope this helps someone along the way.

Set up Eclipse C++ compiler without auto-install or altering System Path on Windows

I am trying to install a C++ compiler on Eclipse without altering the Path variables as I can't, the machine has limited rights. Eclipse obviously runs fine, it's the build that doesn't, it complains about.
The first thing I noticed was a warning that said "Unresolved inclusion" for the libary file stdio.h
I added the path variable inside Eclipse's "Windows > Preferences > C/C++ > Environment" with a new environment variable named "Path" with a path to my minGW/bin folder but to no avail. I also tried setting it to "Replace the native environment variable with specified one" but also no change.
The build errors out saying:
**** WARNING: The "Default" Configuration may not build ****
**** because it uses the "MinGW GCC" ****
**** tool-chain that is unsupported on this system. ****
and then
(Cannot run program "make": Launching failed)
And of course no more. It's a simple Hello World test, so the code shouldn't be an issue. I can see the includes under a folder in the "Includes" area that Eclipse generates (D:\MinGW\binutils\lib) but clicking on them in the Outline tab of Eclipse brings up the error "No include files were found that matched that name".
It looks like you're trying to build a simple hello world program using Eclipse/CDT and a development environment and using mingw as the compiler tool chain. I was able to get this working just now without modifying my system path environment variable. This is what I did:
I already had Eclipse 3.5 (Galileo) installed with CDT
Installed MinGW to C:\MinGW (I assume you already had this done). Make sure the mingw-make component is installed (it's not installed by default, I had to check the box to install this component).
Create a new empty makefile project, add main.c, write hello world code (as you say this isn't the problem so I'm skipping detail here), add a new file called "makefile" and fill it in.
Contents of my main.c file
#include
int main()
{
printf("Hello World!");
return 0;
}
Contents of my makefile:
all:
gcc -o HelloWorld.exe main.c
Open the project properties; Under C/C++ Build uncheck the "use default build command" and change the build command to "mingw32-make".
Under "C/C++ Build/Environment" add a new PATH variable with C:\Mingw\bin in the path
Under "C/C++ General/Paths and Symbols" add C:\mingw\include as an include path.
After doing this, my project built successfully and produced a HelloWorld.exe exectuable in my project.
Another option that doesn't require adding a PATH variable to the system or project properties, or adding the include path to the project properties is to simply gives full path info to the commands in the makefile. For small projects this is manageable. Here's an example makefile:
Contents of makefile:
all:
c:\mingw\bin\gcc -o HelloWorld.exe -I c:\mingw\include main.c
Of course you'll also have to change the build command from simply "mingw32-make" to "C:\mingw\bin\mingw32-make" as well.
Another downside of this approach is that the CDT code parser will not be able to locate include files so you'll have warning in the editor to that effect.