Difference between revisions of "Your First Compile - Windows"

From uGFX Wiki
Jump to: navigation, search
(Setting Your Environment)
(Fix formatting)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This guide will help you set up your first compile under windows.
+
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.
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 ==
 
== Getting the bits ==
Line 11: Line 11:
 
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:
 
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:
 
<ul><li>make</li>
 
<ul><li>make</li>
<li>mingw-binutils</li>
+
<li>mingw64-i686-binutils</li>
<li>mingw-gcc-core</li>
+
<li>mingw64-i686-gcc-core</li>
<li>mingw-w32api</li>
+
<li>w32api-headers</li>
 +
<li>w32api-runtime</li>
 
</ul>
 
</ul>
 +
 +
'''Note:''' Make sure that you install the <code>pc</code> version of the compiler, not the <code>w64</code> one.
  
 
== Set Up Your Folder Structure ==
 
== Set Up Your Folder Structure ==
Select a directory to build your uGFX projects in. The pathname for this should probably not contain spaces (we simply haven't tested that). Create the following folders:
+
Select a directory to build your uGFX projects in.
 +
 
 +
The pathname for this must <b>NOT</b> contain spaces as <code>gmake</code> has BIG problems with paths with spaces in them (yuck!). This applies to any source files as well - <code>gmake</code> simply cannot handle spaces.
 +
 
 +
Create the following folders:
 
<ul><li>uGFX</li>
 
<ul><li>uGFX</li>
 
<li>TestProject</li>
 
<li>TestProject</li>
 
</ul>
 
</ul>
  
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.
+
Into the uGFX directory copy the uGFX source. The uGFX folder will then contain a <code>gfxconf.example.h</code> 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.
+
In the TestProjects directory copy the Makefile from the <code>uGFX/boards/base/Win32/example</code> 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 ==
 
== Setting Your Environment ==
Line 39: Line 46:
 
</code>
 
</code>
  
for a 64 bit version of cygwin.
+
for a 64-Bit version of cygwin.
  
 
== The First Build ==
 
== The First Build ==
Just type "make" to now build your first demo. To run it after building:
+
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:
 +
 
 
<code>
 
<code>
 
.build/TestProject.exe
 
.build/TestProject.exe
Line 50: Line 58:
  
 
== What's next ==
 
== What's next ==
 
 
<ol><li>Try change the GFXDEMO setting in the makefile to make a different demo. The demo's can be found in the uGFX/demos directory.</li>
 
<ol><li>Try change the GFXDEMO setting in the makefile to make a different demo. The demo's can be found in the uGFX/demos directory.</li>
 
<li>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.</li>
 
<li>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.</li>
Line 60: Line 67:
 
<li>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.</li>
 
<li>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.</li>
 
</ol>
 
</ol>
 +
 +
[[Category:Guide]]

Latest revision as of 17:47, 28 November 2018

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.