Product SiteDocumentation Site

2.2. The Ligcc tools

Unlike Windows, Linux generally does not support "build on newer, run on older" development. In other words, the process of compiling the same program on an older system and a newer system can produce different binaries with different requirements.

2.2.1. What is ligcc?

Ligcc is a wrapper around gcc. It allows you to create more portable executables by doing three things:
  • Forces the linker to link against older glibc symbols. Users who are using an older version of glibc will no longer get
    undefined symbol GLIBC_2.4 in /lib/libc.so
    -style error messages.
  • Allows you to easily statically link to any other library.
  • Automatically removes bogus dependencies. For example, your program uses libfoo. libfoo uses libpng internally, but your app does not. Yet the pkg-config file for libfoo specifies -lfoo -lpng is linker parameters. And tadaa - you now have a bogus dependency on libpng! Ligcc automatically removes the -lpng for you if your app doesn't use libpng directly.

    Important

    It is recommended that you use binutils 2.15.94 or later to compile programs, recent versions of ld support the –as-needed argument, which does a much better job than our own dependency stripper, and is faster too.
  • Add $ORIGIN/../lib to the binary's library search path. $ORIGIN is the directory in which the binary exists. This ensures that your binary can find its library dependencies if they are placed in the 'lib' folder under the same prefix. You can drop any dependency library you want in $PREFIX/lib/. Your binary can find those libraries without messing with $LD_LIBRARY_PATH.
  • If you set $LIBUILD_PROJECTNAME, ligcc will also add $ORIGIN/../lib/$LIBUILD_PROJECTNAME to the library search path.