error compiling C code in Eclipse - c

I am new to using Eclipse and CDT and have been trying to get my C code to compile. When I Run As Local C Application, it returns an error message Launch Failed. Binary Not Found. I have MinGW-w64 in C:\mingw-w64. The program compiles and runs fine using gcc via cmd.
I would appreciate if eclipse-proficient users can help out with a how-to. Thanks!

Sometimes, if you try to launch first (before binary has been compiled) eclipse creates launch configuration automatically, that has no binary associated. Later even if you compiled your project (you do this using project/build or hammer icon), it will not associate binary automatically, as it tries to launch your old launch configuration. So:
make sure one of projects source files are selected (in editor for example)
click a down arrow next to bug icon
select debug configurations
select C/C++ application and click on "new launch configuration icon"
If C/C++ application field of your new launch configuration is empty, select search project or browse and tell it where your binary is
optionally set other launch/debug options
launch your new launch configuration using "Debug" button or from "bug" menu

Related

Console App using eclipse and mingw (not launching app in cms.exe)

I am putting together a Windows console app in Eclipse c/c++ Neon (Win 10) and Mingw.
When I run the program the output appears in the console window within Eclipse, but I need/want to be able to debug with the program running a a normal Windows console app (like it would in a vs studio console app).
I have tried adding -mwindows to the minGW in Command line pattern and in linker options. I tried a number of other things I found on the web.
I have spent hours searching and nothing seems to do the trick.
1) Create a file named .gdbinit (or it can be named whatever you want, but this one is the conventional)
2) Add a line set new-console on to the file. Save it.
3) Open "Debug Configurations" in the Eclipse, and select your project debug configuration.
4) Go to the "Debugger" tab.
5) Point the "GDB command file" to the file you have created.
Done! now run this debug configuration.

KDevelop not executing Hello World program

I am using KDevelop 4.6.0 on Ubuntu 14.04.
At one point I saw the output of my hello world program, but now I can build it, but not execute it. That is, if I press the Execute button I am presented with a Launch Configurations dialog which gives me a choice of either a Global configuration or a PlayingAround configuration (my project name). However, no matter which configuration is chosen, nothing happens. No error message, no output, nothing.
Click on that "Add New..." button at the left-top corner. This would allow you to create a launch for any targets created with add_executable from CMake as well as arbitrary executable target.

How can I set KDevelop to compile codes with gcc properly?

I just downloaded KDevelop from Ubuntu Software Center, and have gcc.
I want to see anything happens by pressing F9 but KDevelop says I need to configure a launcher first. And all I know about the setting window is I have to put 'gcc' in somewhere on the window, as well as path to the source code file and path to the executable file it will make.
I have no any knowledge about this window, no any syntax to use in it and can't find it anywhere on the web. Now I desperately require some help. I want to make KDevelop to compile and debug with already-installed gcc and gdb.
It asks you of which executable to debug. You, i suppose, don't want to debug gcc, so you should set this field to your executable. You can also select Project Target option, and choose CMake target that corresponds to your executable.
This step happens after the build step. Make sure your build process is working first (F8).
The window above lets you select which executable in your project should be run when the launch button is pressed.
If your project is created in KDevelop or otherwise uses CMake as the build system, this should be configured by default and use the "target" part of the dialog.
Otherwise the executable should point to the executable you created as part the build process that you want to test.

Eclipse will not run C programs

I just recently installed the CDT plugin for Eclipse in Windows 8 and I'm getting the error:
"Launch failed. Binary not found."
Now I've looked into this and I have installed cygwin with gcc and set that up in Eclipse settings. I went to Window>Preferences>New C/C++ Project Wizard>Makefile Project and checked Cygwin PE Parser (and just in case I checked PE Windows Parser as well).
Then I went to Window>Preferences>Build>Environment and added my PATH variable there. I made sure to add C:\cygwin64\bin to my PATH in my system settings, and I know this is valid because I checked that location and I have successfully run gcc through the command line as well as the cygwin terminal. On top of this, if I build my project in Eclipse and then navigate to that directory outside of Eclipse and run the .exe that it creates by double-clicking on it, it also runs properly.
I'm at a loss for why Eclipse can't run it but everything else can...Any suggestions?
right click your project in eclipse "project explore" -> Run as -> Run configuration
=>select your project name then check "Main" tab, in C/C++ application file. is it point to your binary file?
E.g:
Debug/TestProj.exe

Launch Failed Binary not found Eclipse for C in Windows

I installed Eclipse CDT plugin and also the following packages:
MinSys
MinGW
I have also added paths to their bin in the PATH environment variable. Even then I am unable to compile and run any sample program in Eclipse.
How can I fix this? Thanks for your concern.
I even faced this error and searched a lot to fix. Fortunately, I figured it out myself.
The following are the things you need to make sure they are set:
Window > Preferences > C/C++ > New CDT project wizard > Makefile Project > Binary Parsers
a) Set it to PE Windows Parser if you are on windows.
b) Set it to Cygwin PE Parser if you are using Cygwin
c) Set it to Elf parser if you are using ubuntu
Window > Preferences > C/C++ > Build > Environment
Now click on "select" and select "Path" variable so that you add you path variables in Eclipse.
Now its all done!
All you have to do is write a test program and press Ctrl+B (Build all; there is a button on menu bar) and after that click "Run".
After all the setup is done.Go to eclipse project --> build all or Ctrl + B then eclipse automatically build up the binaries and other stuffs now run your project
Open project properties (Right click on your project, choose Properties on the menu)
C/C++ Build -> Settings
Click on Binary Parsers tab and check PE Windows Parser
In my case
I just save the programme. Press Ctrl + B to build it.
Refresh it.
Then run the programme.
Now you can see this will work fine.
Build
Refresh the project. A new folder named Binaries will appear now in project explorer.
Now Run :)
This problem happened with me. I found the problem that the anti-Virus that I am using considered the binary file as a Trojan and disable the Eclipse from successfully build it. You need to disable the auto-Protection mode, then build the project and run.
Just happened to me and it was a bit silly.
Eclipse didn't show any errors but apparently there was one in the console window.
Double-check that everything's okay there.
Same issue, but on Mac OS on Eclipse Kepler. Fixed with the following configuration
Right click project->properties->C/C++ General->Run/Debug Settings.
I didn't see any launch configuration. So, I created new and input the following entries. Problems is the name of the application :-). Remember that this will only work for Debug project, not for Release or you will have to update the build setting again. Hope this helps.
Select FCC and CDT as your default builder for project. This could help you to solve the problem. By the way, I also encourage you to use Geany program instead. It works ok as well. It's ready to use just only install gcc through MinGW.
I managed to fix this problem by changing the default builder from CDT Internal to GNU Make, by right clicking the project → Properties → C/C++ Build → Tool Chain Editor → Current builder → GNU Make Builder.
Similar problem was faced by me. Once you are within Eclipse IDE try doing the following.
Windows -> Preferences -> C/C++ -> Build -> Environment -> (Add environment variables) -> Click on select all) -> OK
Now, in the same dialog box
New C/C++ project -> Make file project -> Choose Respective Parser* -> Click on Apply and Apply and Close.
Choosing a parser
For Linux - Choose 'Elf Parser' or 'GNU Elf Parser'
For Windows - Choose 'PE Windows Parser'
For Mac OS - Choose 'Mach-o Parser' or 'Mach-o 64 Parser'
Try Building your program and running it. If you still find the Binary Failed Error, Do the following :
Click on Run -> Run Configuration -> C/C++ Application -> click on project_name debug -> click on browse and select your project file -> Press Ok -> below it Browse binary file ( Goto your Eclipse Workspace and select your project file -> You'll find two files 1.Debug 2.Src -> Click on Debug file -> Next click on the file with your project name and Press ok) -> then click apply and press run button.
This should solve the problem.
add third party libraries if in case you are trying to compile OPEN SANKORE project in other projects try to install third party libraries to linux
sudo apt-get install zlib1g-dev libjpeg62-dev libtiff4-dev libmng-dev libpng12-dev
libdirectfb-dev libgstreamer-plugins-base0.10-dev libgstreamer0.10-dev libpulse-dev libaudio-
dev libasound2-dev libfreetype6-dev libfontconfig1-dev libts-dev libcups2-dev libdbus-1-dev
libglib2.0- dev libgtk2.0-dev libx11-dev libxext-dev libxcursor-dev libxfixes-dev libxrandr-
dev libxrender-dev libxv-dev libxinerama-dev libxi-dev libsm-dev libssl-dev libphonon-dev
libt1-dev libpaper-dev
I faced the same problem and tried above methods but no use and when I tried to execute in command prompt it gave me "Application not launched properly ...." error and then I tried with code block it gave me "Application not launched properly..." error. Then I downloaded MinGW from
http://www.equation.com/ It started to work
Even I have faced this similar problem and reason behind this problem is pretty simple that compiler failed to get binary file of your written code.
So where is your mistake ?
Answer is there is something wrong in your eclipse installing process. Yes you have not installed it correctly
Here is solution
First thing is no one know where is defect in installing process even you don't know about that.
and here is tutorial "How to install eclipse correctly".
How to Install Eclipse On Windows for C and C++ Correctly
Trust me after watching this you will find your mistake and binary will be found by your compiler.
Watch this whole 8 minute video, this is only solution I found after 7-8 days of hard work.
I had the same Issue of "binary not found" and I had tried all of the solutions but unfortunately nothing worked. I was trying stuff and found out that when I switched my current toolchain(right click on project click settings->c/c++ build->tool chain editor) Cross GCC to Cygwin GCC, clean all build all and guess what ? I am able to run !!

Resources