Up: Mixing Fortran 77 With C and C++   [Contents][Index] How the Linker is Chosen

When a program or library mixes several languages, Automake choose the linker according to the following priorities. (The names in parentheses are the variables containing the link command.)

  1. Native Java (GCJLINK)
  2. Objective C++ (OBJCXXLINK)
  3. C++ (CXXLINK)
  4. Fortran 77 (F77LINK)
  5. Fortran (FCLINK)
  6. Objective C (OBJCLINK)
  7. Unified Parallel C (UPCLINK)
  8. C (LINK)

For example, if Fortran 77, C and C++ source code is compiled into a program, then the C++ linker will be used. In this case, if the C or Fortran 77 linkers required any special libraries that weren’t included by the C++ linker, then they must be manually added to an _LDADD or _LIBADD variable by the user writing the Makefile.am.

Automake only looks at the file names listed in _SOURCES variables to choose the linker, and defaults to the C linker. Sometimes this is inconvenient because you are linking against a library written in another language and would like to set the linker more appropriately. See Libtool Convenience Libraries, for a trick with nodist_EXTRA_…_SOURCES.

A per-target _LINK variable will override the above selection. Per-target link flags will cause Automake to write a per-target _LINK variable according to the language chosen as above.