#8 Compiling with "-static" fails trying to link RPC functions

open
nobody
None
5
2013-12-25
2013-02-05
Anonymous
No

On some current Linux (Ubuntu and Gentoo) based systems I've tried making the binaries with LDFLAGS=-static and I get errors about missing pmap_* functions (set, unset, etc). So far the only solution I've had is to remove those from the Makefile as I don't really care about RPC related test results. Initially I thought adding "-lrpc" might fix it, but apparently that isn't valid or required. I do see two identical sections in bench.h that are both including rpc/pmap_clnt.h for some reason. Below is the command and error I see. Doesn't matter if 32 bit (i686), 64 bit (x64), or arm (armv7l) based system. Using gcc 4.5.x and 4.7.x on different systems.

gcc -O -DRUSAGE -DHAVE_uint=1 -DHAVE_int64_t=1 -DHAVE_pmap_clnt_h -DHAVE_socklen_t -DHAVE_DRAND48 -DHAVE_SCHED_SETAFFINITY=1 -static -o ../bin/i686-pc-linux-gnu/lat_select lat_select.c ../bin/i686-pc-linux-gnu/lmbench.a -lm
lat_select.c: In function ‘server’:
lat_select.c:134:8: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
../bin/i686-pc-linux-gnu/lmbench.a(lib_tcp.o): In function `tcp_connect':
lib_tcp.c:(.text+0x21b): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../bin/i686-pc-linux-gnu/lmbench.a(lib_tcp.o): In function `tcp_done':
lib_tcp.c:(.text+0x17): undefined reference to `pmap_unset'
../bin/i686-pc-linux-gnu/lmbench.a(lib_tcp.o): In function `tcp_connect':
lib_tcp.c:(.text+0x2b1): undefined reference to `pmap_getport'
../bin/i686-pc-linux-gnu/lmbench.a(lib_tcp.o): In function `tcp_server':
lib_tcp.c:(.text+0x5b9): undefined reference to `pmap_unset'
lib_tcp.c:(.text+0x5e2): undefined reference to `pmap_set'

Discussion

  • Zibri
    Zibri
    2013-05-07

    I solved with: LDFLAGS=-ltirpc