문제

I'm banging my head against the wall here. I'm trying to compile a static linked binary of the Xvfb virtual framebuffer.

http://manpages.ubuntu.com/manpages/natty/man1/Xvfb.1.html

Right now I'm compiling from source like this:

$ sudo apt-get build-dep xvfb
$ apt-get source Xvfb
$ cd xorg-source
$ ./configure --enable-shared=no
$ make

This still results in a compiled binary, but it's still dynamically linked (I'm checking with this command)

find -iname Xvfb -type f -exec file {} \;

It's probably because I need to static link all the dependencies, but I'm having trouble proceeding.

도움이 되었습니까?

해결책 2

This does the trick for me on Ubuntu 12.10/amd64:

# be sure to build static versions of all included libraries
$ ./configure --enable-static

$ make

$ cd hw/vfb
$ make clean

# this provides static versions of some functions which are dynamic only in eglibc
$ sudo apt-get install libtirpc-dev

# LDFLAGS=-all-static asks libtool to do static linking
# LD_EXPORT_SYMBOLS_FLAGS= causes --export-dynamic to be omitted
# LIBS='...' fills in missing dependencies for static libraries
$ make LDFLAGS=-all-static LD_EXPORT_SYMBOLS_FLAG= LIBS='-lfreetype -lgpg-error -lfontenc -ltirpc -lz -lbz2 -lm -lrt -lpthread'

This is a bit of a hack for two reasons:

  1. It hardcodes the library dependencies (which could change in other versions of X)

  2. It introduces an odd dependency on libtirpc. Without it, I got unresolved symbols for xdrmem_create(3) and a few other things which are provided by libnsl when linking dynamically:

    /tmp/xorg-server-1.13.0/os/rpcauth.c:79: undefined reference to `xdrmem_create'
    

다른 팁

Look at the very last link command spewed to the terminal and re-run it yourself (manually), replacing "shared" with "static" (Possible to build a shared library with static link used library?)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top