Previous: Running gnatlink, Up: Linking Using gnatlink

5.2 Switches for gnatlink

The following switches are available with the gnatlink utility:

Display Copyright and version, then exit disregarding all other options.
If --version was not used, display usage, then exit disregarding all other options.
The binder has generated code in Ada. This is the default.
If instead of generating a file in Ada, the binder has generated one in C, then the linker needs to know about it. Use this switch to signal to gnatlink that the binder has generated C code rather than Ada code.
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.
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. The same procedure apply if a C bind file was generated using -C gnatbind option, in this case the filenames are b_mainprog.c and b_mainprog.o.
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.
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 target
Compile your program to run on target, which is the name of a system configuration. You must have a GNAT cross-compiler built if target is not the same as your host system.
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 Directory Options, for further details. You would normally use the -b or -V switch instead.
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".
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.