
Hi,
sorry for an urgent newbie question: how can I create a statically
compiled version of a Haskell program on Linux with GHC that does not rely
on external shared libs (also for any of its libraries it uses)?
I would like to build a binary that works on a 3-processor machine with an
older Linux SMP kernel as well as RH9/FC2.
Thanks in advance,
Jochen
--
Jochen L Leidner

Jochen L. Leidner wrote:
sorry for an urgent newbie question: how can I create a statically compiled version of a Haskell program on Linux with GHC that does not rely on external shared libs (also for any of its libraries it uses)?
Possibly with a great deal of difficulty, depending upon which
functions you need to use.
GNU libc 2.x dynamically loads shared libraries (with dlopen()) for
various "database" lookups (passwd, group, hosts etc). This applies
even when using a static libc (libc.a).
If you need to call (directly or indirectly) any of the functions
which use this mechanism, then you have to either:
a) have (the correct versions of) the relevant libnss_*.so libraries
installed on the target system, or
b) you have to compile your own libc.a using the --enable-static-nss
switch.
The most common functions which require this mechanism are those which
access the passwd database (getpwnam, getpwuid, etc) and those which
perform hostname/domain lookups (gethostbyname etc). Even if you don't
use these functions directly from your program, the libraries which
you use might use them. E.g.:
+ X needs to resolve the hostname part of $DISPLAY, so anything
which uses X is affected.
+ Anything which supports the "~user" syntax to refer to a specific
user's home directory will need to use getpwnam().
+ Anything which needs to translate between UIDs and usernames will
need to use getpwnam() and/or getpwuid().
+ Etc.
--
Glynn Clements
participants (2)
-
Glynn Clements
-
Jochen L. Leidner