[mosh-users] Fwd: statically linking mosh

Charles Curtit c.curtit at gmail.com
Mon Dec 28 05:56:01 EST 2015


Hi everyone,

First of all sorry for the lack of response on IRC, it was 2am at my
place, let's say I didn't hang around very long after asking....

Second, thank you both for your answers.

* Keith's suggestion both worked in it's own right, and also allowed
me to do what I initially wanted. (I'm not very fluent with build
processes, didn't know that particular trick. It will certainly be
very useful in a couple of other projects I'm working with).

* Alex's answer is valid too (indeed I've managed to make it work that
way before). But I wanted to avoid pulling in stuff from EPEL, as it's
not something I'll be able to do in my setup.

Happy new year :)
Charles.








On 28 December 2015 at 02:19, Alex Chernyakhovsky <achernya at mit.edu> wrote:
> Hi Charles,
>
> If you just want to run mosh on CentOS 6, it's available in the EPEL
> repository (e.g.,
> https://dl.fedoraproject.org/pub/epel/6/x86_64/mosh-1.2.4-1.el6.x86_64.rpm).
> If you add the EPEL repository (https://fedoraproject.org/wiki/EPEL)
> you can just "yum install mosh".
>
> Sincerely,
> -Alex
>
> On Sun, Dec 27, 2015 at 8:13 PM, Keith Winstein <keithw at mit.edu> wrote:
>> Hello Charles,
>>
>> Assume that was you on IRC just now, but you may have missed my
>> response. In my experience, linking mosh-server statically basically
>> works fine -- the NSS stuff is generally a non-issue. My technique is
>> just to do ./autogen.sh && ./configure && make. Then I rm
>> src/frontend/mosh-server and run "make V=1" to see the actual linking
>> command-line. Then I take that command-line, remove -fPIE and -pie,
>> and add -static at the very end. Done.
>>
>> I'm sure there's a fancier way to do it too that involves arguments to
>> ./configure, and maybe somebody will chime in, but please do let me
>> know if this doesn't do the trick for you. In general you probably
>> don't want to add a .a archive on the linking command line -- even
>> when linking statically, you do want the default arguments (probably
>> -lprotobuf, but whatever pkg-config gives you) with a -static on the
>> end, and the right thing will happen.
>>
>> Cheers,
>> Keith
>>
>>
>>
>> On Sun, Dec 27, 2015 at 7:00 PM, Charles Curtit <c.curtit at gmail.com> wrote:
>>> 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.
>>> _______________________________________________
>>> mosh-users mailing list
>>> mosh-users at mit.edu
>>> http://mailman.mit.edu/mailman/listinfo/mosh-users
>> _______________________________________________
>> mosh-users mailing list
>> mosh-users at mit.edu
>> http://mailman.mit.edu/mailman/listinfo/mosh-users
> _______________________________________________
> mosh-users mailing list
> mosh-users at mit.edu
> http://mailman.mit.edu/mailman/listinfo/mosh-users


More information about the mosh-users mailing list