Next: , Previous: Naming, Up: Top


5 Usage

The usage of this library is like any other link library. The only important thing is the right linkage order:

  1. The startup code has to be used first :-)
  2. The stubs-library has to be used last since it contains the library base pointers.
  3. The commandline parser should be used after your code but before most other things or you will run into problems.

Normally this is handled by the specs file of gcc.

gcc (-fbaserel) (-resident) -noixemul YOUR_OBJECTS (-lnix_main) (-lm)

If you use ‘-lnix_main’ you get a different commandline parser. ‘-lm’ uses the math library.

Be aware that the formatted I/O-functions need the math library to work correctly for floating point numbers. Without the math library you get only floating point support for simple operators like ‘+’, ‘*’, casts and that like.

If you don't use the assembler inline functions of gcc you will have to use ‘libamiga.a’ if you want to use any Amiga OS function. gcc comes with a free version of libamiga.a which is a subset of the original one. You can build it yourself if you unpack the sources, but be prepared that it may take some time.

For compiling a4-relative programs you should choose the ‘-fbaserel’ option. You get resident (pure) programs if you set the ‘-resident’ option. Anything else necessary for these options is handled by the specs-file (choosing the right startups and libraries).

If you (for some reason) don't trust you specs-file you can call everything by hand:

gcc -nostdlib ncrt0.o YOUR_OBJECTS libnixmain.a (libm.a) libnix.a libstubs.a

But that's not the recommended way. Therefore I don't explain this in detail here - use the ‘-v’ option of gcc for more details.