Your First Compile - Windows

From uGFX Wiki
Jump to: navigation, search

This guide will help you set up your first compile under Windows. We will be compiling one of the uGFX demo's using the command-line. Once you have this working you can later set up any of a number of development IDE's. Please note that this guide will show you how to compile an uGFX application so it can be executed as a native Windows application. That can be compared to a simulator or an emulator - except that it's the real deal. If you are looking for a guide on how to get uGFX running on your target hardware (eg. a microcontroller) then you picked the wrong guide.

Getting the bits

You will need to download uGFX. See Getting Started for how to get the uGFX source code. You will also need to get cygwin [1]. You can either get the 32 bit or 64 bit installer. If you already have cygwin, make sure you update it to the latest version as older versions had problems with the make utility.

Installing Cygwin

Run the installer and accept the default options until you get to the package selection. In the package selection expand the "Devel" branch and add the following packages:

  • make
  • mingw64-i686-binutils
  • mingw64-i686-gcc-core
  • w32api-headers
  • w32api-runtime

Note: Make sure that you install the pc version of the compiler, not the w64 one.

Set Up Your Folder Structure

Select a directory to build your uGFX projects in.

The pathname for this must NOT contain spaces as gmake has BIG problems with paths with spaces in them (yuck!). This applies to any source files as well - gmake simply cannot handle spaces.

Create the following folders:

  • uGFX
  • TestProject

Into the uGFX directory copy the uGFX source. The uGFX folder will then contain a gfxconf.example.h file (as well as lots of other stuff). This folder will be used as the master source location for all your uGFX projects and is generally treated as a read-only store.

In the TestProjects directory copy the Makefile from the uGFX/boards/base/Win32/example directory. This will be your project directory and will eventually contain all your project source files. For now we are going to just build one of the predefined demos so the only thing needed is the makefile itself.

Setting Your Environment

Open a command prompt and set the path for the window to include the cygwin utilities.

PATH=C:\cygwin\bin;%PATH%

or

PATH=C:\cygwin64\bin;%PATH%

for a 64-Bit version of cygwin.

The First Build

Using the command prompt with the correctly set path (as above), change directory to your new project folder (TestProject). Type "make" to build your first demo. To run it after building:

.build/TestProject.exe

You can also use "make clean" to clean up all the object files etc that were created.

What's next

  1. Try change the GFXDEMO setting in the makefile to make a different demo. The demo's can be found in the uGFX/demos directory.
  2. Copy one of the demo's source to your project folder. Comment out the GFXDEMO line in the Makefile and add main.c to the SRC line. Making this will now make the demo from the source in your project directory. Play with your local main.c to experiment with uGFX. Note the gfxconf.h file. This file contains the configuration options for any program you create.
  3. You may want to use an IDE to do your development. Some IDE's worth looking at:
    • Code::Blocks - very easy to set up and use. Set your projects to be a "Custom Makefile" project
    • Eclipse - The standard for cross platform development. Can be tricky for normal windows developers
    • Microsoft Development Studio - The gold standard but pricey and untested with uGFX
  4. You are now in a position to start playing with cross-compiling for other platforms. See some of the examples under the uGFX/boards/base directory.