Difference between revisions of "MINGW Development Package(MAC OS)"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Development Package)
(Required Package)
Line 9: Line 9:
  
 
== Required Package ==
 
== Required Package ==
 +
You might need to get and install the following package:
  
 
<br/>
 
<br/>

Revision as of 23:17, 22 December 2016

This tutorial shows you how to compile a C/C++ program in Mac OS using Eclipse. Remember that GNU is the linux-based compiler and hence if we want to use it for Mac OS, we have to have certain executable(s) to be running in Mac OS.

Development Package

You can get the same development package as the one we promote for ARM processors.


Required Package

You might need to get and install the following package:


Open Eclipse and Create New Project

1. Open Eclipse.
   Always open the MINGW batch file
   since it sets up environment variables for you.

Open MINGW bat file in your development package directory

2. Create a new C/C++ Project

  • Go to File --> New --> C++ Project
  • Name your project anything you want, preferably without spaces.
  • Choose Executable --> Hello World C++ Project and MINGW GCC
  • Then click Finish
Create New Eclipse C++ Project

Create New Eclipse C++ Project

3. Write your source code
   Copy the simple source code on the right.

#include <stdio.h>

int main(void)
{
    /* Without this, printf() will not work */
    setvbuf(stdout, 0, _IONBF, 0);
    setvbuf(stdin,  0, _IONBF, 0);

    /* Write rest of your code here */
    printf("Hello World\n");
    return 0;
}

4. Run your program

  • First, build your program by going to Project --> Build Project
  • Now, go to Run --> Run
  • The output will appear in the Console tab below.
Run your project


4. Optional : Debug your program

  • To perform debugging or run your code one line of code at a time, you can perform debugging.
  • Now, go to Run --> Debug
  • Your program will now "pause" at the main() function.
  • You can now use the Run menu to execute one line at a time.
  • Other hints :
    Double clicking on the code window sets a breakpoint.
    You must press the red stop button to stop your program.
Debug your project