Re: How to create statically linked net-snmp binaries

"Richard Wall" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
On Mon, Apr 7, 2008 at 11:10 AM, Dave Shield <[email protected]> wrote:
> >  ...but ldd snmpd still reports:
>  >
>  >  $ ldd agent/snmpd
>  >         linux-gate.so.1 =>  (0xffffe000)
>  >         libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7f7e000)
>  >         libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0xb7e3b000)
>  >         libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7cf0000)
>  >         /lib/ld-linux.so.2 (0xb7f95000)
>  >         libz.so.1 => /usr/lib/libz.so.1 (0xb7cdb000)
>
>  The first thing that springs out about that list is that it doesn't mention
>  any of the Net-SNMP libraries.   So you are successfully statically
>  linking with *those*, at least.

Thanks Dave,

Actually, I was about to email the list to say that I did manage to
create an entirely self contained binary.

Trick is to manually run the last gcc command reported by make,
appending the argument -static. So you do:

make agent

...when its finished you change to the agent subfolder and run gcc
with argument -static...

gcc -static -Ulinux -Dlinux=linux -o snmpd snmpd.o
-L/home/richard/src/net-snmp-5.4.1/agent/.libs

...which produces various warnings...

/home/richard/src/net-snmp-5.4.1/snmplib/.libs/libnetsnmp.a(snmpv3.o):
In function `setup_engineID':
snmpv3.c:(.text+0xcef): warning: Using 'gethostbyname' in statically
linked applications requires at runtime the shared libraries from the
glibc version used for linking

...but results in...

ldd snmpd
        not a dynamic executable

...which so far has been working well for me.

I guess the problem is in the agent Makefile, but I haven't had a
chance to look very closely.

-RichardW.
-- 
Richard Wall
http://www.appliansys.com

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.