Copyright (c) 2012-2016 Hyperion Entertainment and contributors.

Programming AmigaOS 4: The Development Environment

From AmigaOS Documentation Wiki
Jump to: navigation, search

This article was adapted from Amiga Future magazine's series on developing for AmigaOS....

We were shocked when we realised that while we've covered several subjects in programming for AmigaOS 4 in Amiga Future there's been no extensive coverage of all of the many aspects. Additionally, since the release of AmigaOS 4, quite a lot of time has passed by, and during that time new programming treasures have sneaked into the SDK virtually unnoticed. It's been nine years since the authors did a similar series in "Amiga Magazin". So, we're launching a new 15-part series starting with a short peek at the SDK and the available development environments.

SDK

The Software Development Kit (SDK) for AmigaOS 4 has had some updates. You can find the latest version on from March 2010 on Hyperion Entertainment's website. The archive is easy to install and you can select which components you require. The base archives are always installed, and if you wish to use additional contributions you can select the appropriate archives. The installation has already been covered in Amiga Future 81 page 28 (link) and issue 84 page 17 (link). The SDK: assign holds all documentation (Autodocs) and include files (include/include_h), the latter are required for developing your own code and they're included in the compiler's search path.

AF103 sdk installer.png

Compiler

The package installs the gcc compiler version 4.2.4, suitable for developing programs in C and C++. You can also create shared libraries, link libraries and shared object files (sobj). A detailed description of gcc and its command-line options can be found in SDK:Documentation.

Development Environment

Currently, the only complete development environment is Codebench. It allows you to easily join several files into a project, the makefile is created automatically. You can call the compiler directly from the DE.

There's the new StormC5 Editor, optimized for developers, with several features. We've covered this editor in Amiga Future's previous issue 102. StormC5 is planned to become a complete DE with project management and "integrated" compiler again.

AF103 programmcode eng.png

Additional editors are CygnusEd and GoldEd. Also, the operating system's Notepad is generally suitable for creating code, probably limited to smaller/shorter programs however.

Generally, you can still use the older environments MaxonDevelop and StormC4. They feature project management and editors and provide for managing projects and editing the source code files. The required makefiles would need to be created manually however, the same applies to compiler or make calls.

Documentation

A constant issue is the inadequate, incomplete, and even some missing, documentation to the application programming interface (API). The first place to go would be the Autodocs files, at least providing short descriptions for each function, what parameters are to be passed to the function, which return values there are, and what purpose the function serves. The Autodocs should cover all functions although not always with up-to-date descriptions.

Fortunately, there is this wiki where you can find numerous descriptions and sample code. Additionally, you can try to contact fellow developers. If you require more of a tutorial or description of the architectural aspects you should look into the RKRMs revised and updated on this wiki. A look into OS4Depot can also provide helpful tools and sample code for developers. A short overview has been given in issue 79 page 25.

The first step

To avoid keeping this first part all theoretical we'd like to use a mini program to check whether AmigaOS version 4.1 (or better) is installed.

/*
** check_os4.1.c : Check for AmigaOS 4.1 enviroment
** gcc check_os4.1.c -o check_os4.1
*/
 
#include <proto/exec.h>
#include <proto/dos.h>
 
int main()
{
  int res;
 
  if(SysBase->lib_Version >= 53)
  {
    IDOS->Printf("AmigaOS 4.1 is available !\n");
    res = RETURN_OK;
  }
  else
  {
    IDOS->Printf("This program requires AmigaOS 4.1\n");
    res = RETURN_FAIL;
  }
 
  return res;
}

You can compile it directly from the console by

gcc check_os4.1.c -o check_os4.1

When run it'll output an appropriate text. This codeblock is suitable if you want to make sure that your program requires a specific OS version. For this, these values are significant: 50 stands for AmigaOS 4.0 preview, 51 for 4.0 final, 52 for 4.0 update 4 and the current 53 for 4.1. Generally, you can expect version 53 to be running.

Authors

Written by Michael Christoph and Nils Petersen
Copyright (c) 2013 Michael Christoph