It's common to hard-code such references at compile time, and perhaps provide a command line option or environment variable to override the compile-time default. Often the program just remembers the location of one configuration file (typically under
/etc) where any compile-time defaults can be overridden. This approach makes most sense for open source software that is compiled by the same people that make the operating system, as part of a Linux distribution or BSD ports.
For applications distributed in a binary form, the usual approach is to locate the application binary from its zeroth argument. By convention, the zeroth argument to
argv) is the path to the binary (it's up to the caller, often a shell, to respect the convention). If
argv doesn't contain any
/, the application should perform
$PATH lookup on it.