Index


RISC World

Easy C++ Manual

Copyright © ProAction and APDL, 2001

The linker

The linker is used to link together one or more object files together with functions from one or more libraries, to produce executable code. It is compatible with object files generated by the C Compiler as well as other compilers and assemblers. The C linker is contained in the same module as the compiler, and is loaded in the same way.

The general form of the link command is:

*link filename,... [qualifiers]

Qualifiers are keywords that modify the operation of the linker, and are described in detail below.

By default, the linker links the object code in subdirectory o of the current directory, and produces executable code which is placed in the current directory using the same name as the object file. It also links to the library specified by the system variable Lib$Library. By default this is STDCLib ; the shared C library. For example:

*link HelloW

links o.HelloW to the library STDCLib, and produces the executable file HelloW . This naming convention is similar to that provided in many other C systems, but may be altered by modifying the system variables C$Object and Link$Image, which are set by default to o. and "" respectively.

Linking multiple files

To link a number of files together, use:

*link part1,part2,part3

The commas separating the filenames must be included. The executable code produced by this command is called part1 (the name of the first object file), and is put in the current directory.

Linker qualifiers

The operation of the linker can be controlled by appending qualifiers to the link command. A full list of qualifiers can be displayed by typing:

*help link

The format of the listing produced is similar to that described earlier for the compiler.

   Quali fier    -image

   Abbreviation    -i

   Default    -image

Normally the image (executable) file produced by the linker is given the same name as the first object file, and is put in the current directory. The -image qualifier allows you to specify a different path and filename for the executable file, for example:

*link HelloW -image=$.helloprog

It is useful if you wish to re-link a file without overwriting the previous executable file. It can also be used to prevent executable code from be generated, thus:

*link HelloW -noimage

In this case the linking will still take place, and any errors reported, but no file will be produced.

   Quali fier    -library

   Abbreviation    -l

   Default    -library=STDCLib

The -library qualifier specifies the library or range of libraries to be linked to the specified object files. Easy C is supplied with 2 libraries: STDCLib which is the Shared C Library containing all the standard ANSI functions, and ROSLib containing operating system, graphics and sound functions. The Shared C Library is contained in the relocatable module Clib, which must be present for programs to run.

If the -library qualifier is not present, the linker links to the default library STDCLib , for example:

*link HelloW

To link to a number of libraries, specify their names after the -library qualifier, for example:

*link HelloW -library=STDCLib,ROSLib

C searches for the libraries according to the path specified by the system variable Link$Library which by default is set to !EasyC.Libraries .

The next section of this user guide describes the commands which enable new libraries to be created and maintained.

   Quali fier    -base

   Abbreviation    -b

   Default    -base=&8000

The -base qualifier sets the base address of the executable code. For example:

*link HelloW -base=&A000

The default base is &8000. To execute code with a base address other than &8000, you must load it at the new address and use *go to run it.

   Quali fier    -debug

   Abbreviation    -d

   Default    -nodebug

This qualifier is used to specify that debugging information should be generated for use with a separate source level debugger.

   Quali fier    -map

   Abbreviation    -m

   Default    -nomap

The -map qualifier is used to produce a map of the functions linked by the -link qualifier. Map files are normally saved in subdirectory map of the current directory using the same name as the object file. The map subdirectory name is specified by the system variable Link$Map.

*link HelloW -map *link HelloW -map=$.mapfile

   Quali fier    -throwback

   Abbreviation    -th

   Default    -nothrowback

This qualifier causes errors generated by the compiler to be transmitted to a suitable editor using the throwback facility. Editors currently supporting throwback include SourceEdit and DeskEdit. This facility is only intended for use from the Easy C front-end in the desktop.

   Quali fier    -desktop

   Abbreviation    -des

   Default    -nodesktop

This qualifier causes the compiler to ignore the usual directory naming conventions, and accept full pathnames for source and object files. This facility is only intended for use from the Easy C front-end in the desktop.

APDL and ProAction

 Index