Saturday, July 26, 2014

Run a C/C++ Program in windows Eclipse IDE

1. Install CDT plugin which suits your eclipse release.
2. Download mingw or cygwin (mingw suggested).
3. Right click  Properties -> C/C++ Build -> Tool chain editor -> Current toolchain (select MinGW GCC)
4. Set the Environment path variables
         Right click Properties -> C/C++ Build -> Environment -> add PATH variable and value is <path to
         bin of mingw>  For ex: PATH : C:\mingw\bin
5. Set the make command
        Right click Properties -> C/C++ Build -> Settings -> Tool chain (tab) -> GCC C Compiler
            clear the existing command and add mingw32-gcc
        Also select MinGw Linker and select the command , replace with mingw32-gcc
6. Binary parser
      Right click Properties -> C/C++ Build -> Settings -> Binary Parsers (tab)
            check PE Windows Parser.
7. Cttl + B to build ( or you can click on hammer icon 
8.  Sample code
     #include <stdio.h>

int main() {

float x = 0.5;
if(x == 0.5) {
printf("IF");
} else if(x == 0.5f) {
printf("ELSE IF");
} else {
printf("ELSE");
}
return 0;
}

9. Run it
10. Result is 'IF'

     Happy coding.

No comments:

Post a Comment