[mosh-users] statically linking mosh

Charles Curtit c.curtit at gmail.com
Sun Dec 27 20:00:27 EST 2015


Hi people,


I'm trying to run mosh on centos 6 machines. And to a large extent, I
have succeeded to do that in the "normal" way. ie: compile stuff on
the machines I will use, and modify LD_LIBRARY_PATH adequately.

What I'm trying to do now is avoid having to modify the
LD_LIBRARY_PATH env on all machines, avoid having to compile protobuf
on all machines. Since I need to do that because of protobufs, I'm
looking for a way to statically link protobuf into the binary then
distributed that. I have so far failed.

When I statically compile the whole binary, I run into problems with
glibc (because of nss mostly, and missing dlopen, dl* symbols), and
when I try to statically link only /usr/local/lib/libprotobuf.a, I run
into trouble at link time for this library.


I compile protobufs like this:

./configure (tried --disable-shared and --static and both without
success, the error is always the same when compiling mosh)
make
make install (goes to /usr/local/lib/protobufs....)

Then I compile mosh like so:

./configure protobuf_LIBS="/usr/local/lib/libprotobuf.a"
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
make

And after a little while I get this :
  CXXLD  mosh-client
/usr/bin/ld: /usr/local/lib/libprotobuf.a(common.o): relocation
R_X86_64_32S against `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_Rep::_S_empty_rep_storage' can not be used
when making a shared object; recompile with -fPIC
/usr/local/lib/libprotobuf.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[3]: *** [mosh-client] Error 1
make[3]: Leaving directory `/root/Downloads/mosh-1.2.5/src/frontend'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/Downloads/mosh-1.2.5/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/Downloads/mosh-1.2.5'
make: *** [all] Error 2


Don't know how to make this work... If I replace libprotobuf.a by
libprotobuf.so, it compiles ok, but checking with ldd, the binaries
produced do dynamic linking against libprotobuf.so, which is what I'm
trying to avoid.

I can't wrap my head around what exactly does protobuf_LIBS and the
interaction with PKG_CONFIG_PATH, so perhaps there is something
there...
Thanks for any help !
Charles.


More information about the mosh-users mailing list