Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am not able run C program in eclipse

Tags:

c

eclipse

I've been googling for about 2 days. Read and followed a lot of instructions but nothing worked for me (including some instructions in this website; I know that people already asked this question in here). I've downloaded Eclipse, installed the C/C++ plugin (window 7, 64 bit) but when I run the HelloWorld.c program, I get a pop-up message saying:

Launch Failed. Binary Not Found.

Here is what I have done in Eclipse:

  1. Window-->Preference-->New CDT Project Wizard-->Makefile Project-->Binary Parswer, make sure there is a checkmark infront of: "PE Window Parser".
  2. Project-->Properties-->C/C++ Build-->Settings-->Binary Parsers, make sure there is a checkmark infont of "PE Window Parser".
  3. Project-->Properties-->C/C++ Build-->Tool Chain Editor: in the Current toolchain, select: Cross GCC in the Currect builder, Select: Gnu Make Builder.
  4. set Eclipse CDT Auto Build

Here are steps I used to create the project:

  1. File-->new-->C Project. enter "Hello" in the "Project name:" field. Click Next button, make sure both Debug and Release are checked, click Next button again, click Finish button.
  2. Right click on Hello-->new-->Source File, enter HelloWorld.c, then click Finish button. enter the code below:

    #include <stdio.h>
    int main()
    {
    printf("Hello, world!\n");
    return 0;
    }
    
  3. Save and click on the "Hammer" icon to build project. then I got this message:

make all

Cannot run program "make": Launching failed

Error: Program "make" not found in PATH PATH=[C:\eclipse_Juno;C:/Program Files (x86)/Java/jre7/bin/client;C:/Program Files (x86)/Java/jre7/bin;C:/Program Files (x86)/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;

21:35:25 Build Finished (took 280ms)

  1. Right click in the Text Editor area, Run As-->Local C/C++ Application a message pop up said: "Launch Failed.Binary not found"

I am not sure what I did wrong. Please point out why I am not able to run my program in Eclipse. Thanks in advance.

like image 824
Danny Phung Avatar asked Mar 18 '13 03:03

Danny Phung


People also ask

Why is my program not running in Eclipse?

Make sure the affected project is open, then go to Project->Preferences. Select the C/C++ Build pane, then make sure the build toolchain is using MinGW, not Cygwin. If you still have trouble running your applications, go back to Project->Preferences and look for the run/debug pane.

Can I run C program in eclipse?

Eclipse is popular for Java project development. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Linux and Mac OS.

Can I use Eclipse for C and Java?

Eclipse is a popular integrated development environment (IDE) for developing Java and C++ applications. You can install plugins that provide special features for specialized development frameworks, such as ANTLR 4.


2 Answers

The problem was that no compiler was installed, and that eclipse is an integrated development environment which doesn't integrate a compiler natively.

like image 190
Étienne Avatar answered Oct 29 '22 21:10

Étienne


I had the same problem minutes ago. Do this:

Write your program, like:

#include <stdio.h>

int main(){
    printf("Hello There\n");
    printf("salam");
}

Then press Ctrl + B for Build All. You can do this from Project -> Build All.

Then, go to Run -> Run Configuration and on the left menu, double click on C/C++ Application (1), then click on the new opened option: "Sth Debug"(2). Now, on the main window, under C/C++ Application:, under the edittext, click browse option(3). Open your workspace, open your project, open Debug folder (which is created after each build), and select your a file with the same name as ProjectFolderName, then click Run (8).

Important Note: Just select the file with the same name as ProjectFolderName without any suffix. Don't choose the files ending like: sth.d or sth.o. Just select file which has no suffix.

Important Note2: You can put ${workspace_loc}/${project_name}/Debug/${project_name} in the edittext too, but if you are using Windows, use backslashes() instead of slashes(/).

Look at the picture

like image 27
Mohammad Kholghi Avatar answered Oct 29 '22 23:10

Mohammad Kholghi