LCC-win32: Introduction

From The Uniform Server Wiki
Revision as of 12:39, 4 October 2008 by Ric (talk | contribs) (New page: {{Uc nav lcc-win32}} '''LCC Introduction''' On the forum someone asked the following question; what compiler was used to compile “unicontroller”? After looking through Uniform Server...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

MPG UniCenter

MPG UniCenter

lcc-win32 C compiler.

LCC Introduction

On the forum someone asked the following question; what compiler was used to compile “unicontroller”? After looking through Uniform Server’s doc folder I discovered it was compiled using lcc-win32. Coincidentally I have just re-installed this to create a small delay utility. Lcc-win32 is a small but excellent free “C” development environment. At first sight it looks complicated however compared with commercial offerings it really is far easier to set-up and use.

This quick-start guide will show you how to set-up lcc-win32 and compile a small project.

Project

There’s no point in just reading, I like practical hence the project will be to create a small delay utility.

Every program you create requires a place to put all the files. Effectively you need to create a new folder within lcc's project folder.

First decide on a name you want to use for your project it can be anything you like, I will be using “uniform_server_delay”. Next choose a name for your program again this can be anything you like I want to produce a small utility named unidelay.exe.

With the project names defined we are ready to set-up the working environment, however first we need to install lcc-win32.

Top

Download

Download a copy from Software Solution the file you are looking for is Lcc-win32 (lccwin2.exe) at the bottom of this page

Top

Install

Installation is just a matter of a few mouse clicks.

  1. To start the installation process double click on lccwin32.exe
  2. Click Yes to continue, click Next
  3. Click Yes to licence Agreement
  4. Information click Next
  5. Select Destintion directory I selected drive E and used the default folder lcc. Click next
  6. Select Program Group. Change this if you want to. The default is fine, click Next
  7. Ready to install, click Install
    Files are copied and the build process starts. Wait for this to end.
  8. When libraries generation finishes an alert box is displayed. Click OK
  9. Click finished.

Top

Run

Once installed run the program:

start > All Programs > Lcc-win32 > click Lcc-win32

Top

Create a console project

I previously mentioned every program you create requires a place to put all the files (project name) and a program name defined as follows:

  • Project name: uniform_server_delay
  • Program name: unidelay

This is where that information is used:

Create project folder

Project set-up

  1. Click Project (A), click Create (B), this opens-up Definition of new project.

Note:
After creating a more than one project the Project dropdown menu allows you to open, close and delete projects. When lcc is first start it opens the last project opened.

Of real importance is the first item Configuration; this opens a window with various tabs notably Compiler, Linker and Debugger see last three images on this page.

Project folder set-up

You will see there are three fields: Name of the project, Sources and Output directory.

The following creates a project folder

  1. Enter the name of your project (c) uniform_server_delay
  2. To the right of "sources" click Browse (D), navigate to E:\lcc\projects click OK.
    In the source window you will see E:\lcc\projects add your project name to the end of this to give
    E:\lcc\projects\uniform_server_delay
  3. Click in "Output directory" (F) the box will automatically complete if not type this in
    E:\lcc\projects\uniform_server_delay\lcc
  4. Leave the type of project unchanged (my delay utility is a simple console app)
  5. Click Create (G).

Note: After clicking create, a pop-up displays "do you want to use the wizard"

Click "Yes" This really does make life easier! Use it.

Use the Wizard

Executable file name set-up

An "Application characteristics" window opens.

  1. You only need to change the top left name (H) to the executable name you want to create.
    I want to create unidelay.exe hence I type in the name unidelay.
  2. Click in "Output directory" box (I) all other entries will automatically update.
    Note: You will find this automatic update on several forms.
  3. Click OK (J)

A pop-up confirms "unidelay" created in e:\lcc\projects\uniform_server_delay.

Click OK

Essentially that completes the set-up; all that remains is to click through reaming menus and accept their defaults.

Compiler

Compiler settings page displayed click Next

Note:

When creating a new project the Complier page is displayed without tabs and the OK button is replaced with the Next button.

Once you have completed and debugged your program the final stage is to change the settings on this page and recompile your project.

  • Check Optimize box (A) – Reduces code size
  • Check Elminate unused assignments (B) – Reduces code size
  • Uncheck Generate debug info (C) – Debug code will not be included again reduces code size.

Linker

Linker settings page displayed click Next

Note:

When creating a new project the Linker page is displayed without tabs and the OK button is replaced with the Next button.

Once you have completed and debugged your program the final stage is to change the settings on this page and recompile your project.

After changing settings in the Compiler they are reflected in the Linker make sure the “Do not include the debug information” box (C) has been checked.

Debugger

Debugger settings page displayed click Finish

Note:

When creating a new project the Debugger page is displayed without tabs and the OK button is replaced with the Finish.

During development and debugging you can pass parameters to you application by entering them in box (A). These are the command line parameters you would enter when running your program

After all that you end up with a single console page template.

OK you can delete its contents and add your own code. What is more important everything has been setup.

Top

Folder hierarchy

For completeness I have included the project folder structure.
The highlighted project folder is the one just created.
This contains the following files:

  • unidelay.c – This is the source code if you wish you can edit this in another editor.
  • unidelay.prj – lcc updates this do not edit.

Sub-folder lcc

When you compile your project several files are generated:
Makefile, unidelay.dep, unidelay.err, unidelay.obj and the final program unidelay.exe

Final note:

You will notice I have created two other project folders unicontroller (windows application)
and uniform_server_uniserv (console application).

After setting-up each project folder using the wizard I copied source code from Uniform Server's doc folder.

Top

Summary

I have shown how to install lcc-win32 and how easy it is to create a project using the wizard. Images I find help with orientation and provide a good reference point. With the project set-up its time to look at the source code and compiling this is covered on the next page.

Top


Ric