Switches for gnatlink (GNAT User’s Guide for Native Platforms)

#### 4.6.2 Switches for `gnatlink` ¶

The following switches are available with the `gnatlink` utility:

`--version`

  Display Copyright and version, then exit disregarding all other options.

`--help`

  If `--version` was not used, display usage, then exit disregarding all other options.

`-f`

  On some targets, the command line length is limited, and `gnatlink` will generate a separate file for the linker if the list of object files is too long. The `-f` switch forces this file to be generated even if the limit is not exceeded. This is useful in some cases to deal with special situations where the command line length is exceeded.

`-g`

  The option to include debugging information causes the Ada bind file (in other words, `b~mainprog.adb`) to be compiled with `-g`. In addition, the binder does not delete the `b~mainprog.adb`, `b~mainprog.o` and `b~mainprog.ali` files. Without `-g`, the binder removes these files by default.

`-n`

  Do not compile the file generated by the binder. This may be used when a link is rerun with different options, but there is no need to recompile the binder file.

`-v`

  Verbose mode. Causes additional information to be output, including a full list of the included object files. This switch option is most useful when you want to see what set of object files are being used in the link step.

`-v -v`

  Very verbose mode. Requests that the compiler operate in verbose mode when it compiles the binder file, and that the system linker run in verbose mode.

`-o `exec-name'`

  `exec-name` specifies an alternate name for the generated executable program. If this switch is omitted, the executable has the same name as the main unit. For example, `gnatlink try.ali` creates an executable called `try`.

`-B`dir'`

  Load compiler executables (for example, `gnat1`, the Ada compiler) from `dir` instead of the default location. Only use this switch when multiple versions of the GNAT compiler are available. See the `Directory Options` section in The_GNU_Compiler_Collection for further details. You would normally use the `-b` or `-V` switch instead.

`-M`

  When linking an executable, create a map file. The name of the map file has the same name as the executable with extension “.map”.

`-M=`mapfile'`

  When linking an executable, create a map file. The name of the map file is `mapfile`.

`--GCC=`compiler_name'`

  Program used for compiling the binder file. The default is `gcc`. You need to use quotes around `compiler_name` if `compiler_name` contains spaces or other separator characters. As an example `--GCC="foo -x -y"` will instruct `gnatlink` to use `foo -x -y` as your compiler. Note that switch `-c` is always inserted after your command name. Thus in the above example the compiler command that will be used by `gnatlink` will be `foo -c -x -y`. A limitation of this syntax is that the name and path name of the executable itself must not include any embedded spaces. If the compiler executable is different from the default one (gcc or <prefix>-gcc), then the back end switches in the ALI file are not used to compile the binder generated source. For example, this is the case with `--GCC="foo -x -y"`. But the back end switches will be used for `--GCC="gcc -gnatv"`. If several `--GCC=compiler_name` are used, only the last `compiler_name` is taken into account. However, all the additional switches are also taken into account. Thus, `--GCC="foo -x -y" --GCC="bar -z -t"` is equivalent to `--GCC="bar -x -y -z -t"`.

`--LINK=`name'`

  `name` is the name of the linker to be invoked. This is especially useful in mixed language programs since languages such as C++ require their own linker to be used. When this switch is omitted, the default name for the linker is `gcc`. When this switch is used, the specified linker is called instead of `gcc` with exactly the same parameters that would have been passed to `gcc` so if the desired linker requires different parameters it is necessary to use a wrapper script that massages the parameters before invoking the real linker. It may be useful to control the exact invocation by using the verbose switch.