Statically linking vim with gcc
I need a version of vim to run while I am in single-user
mode and don't have access to shared libraries.
How can I make a statically linked vim?
Is there an option to 'make' or 'configure'
that will cause the compiler to produce a
statically linked vim binary?
I have tried CFLAGS = -static
- Previously Steve Davidson wrote:
> I need a version of vim to run while I am in single-userWhy don't you have access to shared libraries when you are in
> mode and don't have access to shared libraries.
single-user mode? You probably only need to compile a minimal
vim which only uses libraries in /lib, which is available in
> I have tried CFLAGS = -staticThe magic word is probably LDFLAGS here, not CFLAGS.
/ Generally uninteresting signature - ignore at your convenience \
| wichert@... http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0 2805 3CB8 9250 2FA3 BC2D |
> From: Steve Davidson <sdn@...>I use "-Xlinker -Bstatic" to switch the linker to static mode. I
> How can I make a statically linked vim?
> I have tried CFLAGS = -static
only do this for the gtk/glib libraries, but if you put it before
any "-l" options, it applies for the entire link. Note that on my
system, some libraries are not available in a static form (i.e.,
only the dynamic (.so) library exists). This makes an entirely
static build a little difficult. 8-]
Stephen P. Wall Redcom Laboratories, Inc. / __ /\/ ___/\
Steve_Wall@... One Redcom Center ___/ /\/ /_/ /\__\/
(716) 924-7550 Victor, NY 14564 /_____/ /_______/ /
x300 USA \_____\/\_______\/
- Stephen P. Wall writes:
> I use "-Xlinker -Bstatic" to switch the linker to static mode. IThere should be no problem selecting only a subset of the libraries,
> only do this for the gtk/glib libraries, but if you put it before
> any "-l" options, it applies for the entire link. Note that on my
> system, some libraries are not available in a static form (i.e.,
> only the dynamic (.so) library exists). This makes an entirely
> static build a little difficult. 8-]
i.e. those that are available as static archives, for static linking.
With many linkers you may place the respective linker options more
than once in between the -l flags, like:
libs = -lfoo -Wl,-Bstatic -lbar -lbuzz -Wl,-Bdynamic -lfrob \
-Wl,-Bstatic -lfred -lfrobozz
In this example, libfoo and libfrob will be dynamically linked,
whereas libbar, libbuzz, libfred, and libfrobozz will be linked
The HP-UX linker even allows to specify preferences in arbitrary
order, i.e., take the static one if available and the dynamic one if
not, or vice versa. Have a look at ld(1) and see what your linker has