Difference between revisions of "Installation of Software Development Kit and its basic usage"

From MorphOS Library

(Contents dump.)
 
m (Installing SDK: named user-startup as script, not file, it is more descriptive)
Line 16: Line 16:
 
The first step of instalation is to download the SDK archive from [http://www.morphos.net morphos.net] site, or by clicking [http://www.morphos-team.net/files/sdk-20100617.lha direct link]. The SDK is delivered as a LhA archive, which must be depacked before proceeding. The easiest way is to open a context menu for the archive (with RMB in an Ambient window) and choose ''Extract''. After depacking we will get a directory named ''morphossdk'' with an ''Installer'' application and a big file named ''sdk.pack'' inside. Installation is started by running ''Installer''. The only option here is to choose an installation directory. Then there is a time for watching a progress bar...
 
The first step of instalation is to download the SDK archive from [http://www.morphos.net morphos.net] site, or by clicking [http://www.morphos-team.net/files/sdk-20100617.lha direct link]. The SDK is delivered as a LhA archive, which must be depacked before proceeding. The easiest way is to open a context menu for the archive (with RMB in an Ambient window) and choose ''Extract''. After depacking we will get a directory named ''morphossdk'' with an ''Installer'' application and a big file named ''sdk.pack'' inside. Installation is started by running ''Installer''. The only option here is to choose an installation directory. Then there is a time for watching a progress bar...
  
After the instalation a system reboot may be needed to update system assigns and paths (the SDK adds some commands to the ''S:user-startup'' file, which is executed at boot).
+
After the instalation a system reboot may be needed to update system assigns and paths (the SDK adds some commands to the ''S:user-startup'' script, which is executed at boot).
  
 
==Choosing compiler==
 
==Choosing compiler==

Revision as of 00:12, 22 October 2010

Grzegorz Kraszewski

Installing SDK

The official MorphOS SDK provides a complete environment for creating programs for MorphOS. It contains following components:

  • MorphOS includes (for MorphOS native API).
  • Standard C and C++ library includes.
  • MorphOS API documentation and example code.
  • Two GCC compilers, 2.95.3 and 4.4.4.
  • GCC toolchains (one for every compiler), sets of developer utility programs.
  • MorphED, a simple programmer's texteditor.
  • Perl scripting language (used by some SDK tools).

The first step of instalation is to download the SDK archive from morphos.net site, or by clicking direct link. The SDK is delivered as a LhA archive, which must be depacked before proceeding. The easiest way is to open a context menu for the archive (with RMB in an Ambient window) and choose Extract. After depacking we will get a directory named morphossdk with an Installer application and a big file named sdk.pack inside. Installation is started by running Installer. The only option here is to choose an installation directory. Then there is a time for watching a progress bar...

After the instalation a system reboot may be needed to update system assigns and paths (the SDK adds some commands to the S:user-startup script, which is executed at boot).

Choosing compiler

As mentioned above, the SDK delivers two GCC compilers: an old but trusty 2.95.3 one, and modern 4.4.4. There is a tool named GCCSelect in the SDK, which allows fast switching between compilers. Just type in shell

GCCSelect 2.95.3

or

GCCSelect 4.4.4

to change the current compiler. GCCSelect works by making symbolic links to proper version of GCC and its tools, so the compiler is always called as gcc or g++, regardless of version choosen currently.

Which one to choose? It depends on code compiled and other constrains. Here is some guidance:

  • 2.95.3 compiles faster and consumes less memory.
  • For old code 2.95.3 would be better, as 4.4.4 will produce tons of warnings or even errors on code being flawlessly compiled by the old GCC.
  • For new projects, especially written in C++, GCC 4.4.4 is recommended, as the old one simply does not keep up with nowadays standards.
  • 4.4.4 usually produces faster code (but sometimes also bigger, depends on optimizer options).
  • 4.4.4 as relatively new and complex compiler, may contain more bugs than 2.95.3.

My general advice is to use GCC 4 and only switch to GCC 2 if needed.

Standard C and C++ libraries

These standard libraries are parts of C and C++ language specifications respectively. They mainly deliver file and console input/output functions, mathematic functions and string operartions. C++ library provides also a set of basic container classes.

There are two ways to access these libraries on MorphOS. The first (and default) one is using a MorphOS shared library ixemul.library. As the name suggests, this library tries to provide some Unix environment emulation on MorphOS, which, except of standard libraries, includes large part of POSIX standard and some other commonly used functions. ixemul.library is usually used for porting big projects from Unix/Linux world, for example it is used by GCC itself and many other tools in SDK.

The second way is to use libnix (as lib no ixemul). In contrast to ixemul.library, libnix is statically linked with the application. This is the preferred way for providing standard libraries for MorphOS native applications. It is achieved by passing -noixemul flag to the compiler. libnix delivers full C and C++ libraries, but its POSIX implementation is less complete. While an executable compiled with libnix is usually bigger (because of static linking), the total memory consumption may be lower, as an application using ixemul.library will load it to memory as a whole, while application linked with libnix loads only actually used functions. On the other hand ixemul.library may be shared by multiple applications.

Another alternative is to not use standard libraries at all. It may sound crazy for the start, but MorphOS native API provides complete file and console I/O as well as some string manipulation functions and most of mathematic functions. Using native API makes applications faster and smaller in size. On the other hand code using MorphOS API directly is not portable to non-Amiga(like) systems. A -nostdlib compiler option instructs compiler to not link the code with the standard library.