PDA

View Full Version : problem with --enable-static


richlv
19-10-2005, 16:12
zabbix 1.1beta1, gcc 3.3.6

when --enable-static is used, compilation fails :

./configure --enable-agent --enable-static && make

...
gcc -static -g -O2 -o zabbix_agent zabbix_agent.o ../libs/zbxsysinfo/libzbxsysinfo.a ../libs/zbxsysinfo/linux/libzbxsysinfo2.a ../libs/zbxlog/libzbxlog.a ../libs/zbxcrypto/libzbxcrypto.a ../libs/zbxnet/libzbxnet.a ../libs/zbxconf/libzbxconf.a ../libs/zbxcommon/libzbxcommon.a
../libs/zbxsysinfo/libzbxsysinfo.a(common.o)(.text+0xcb3): In function `PROC_NUM':
common/common.c:769: warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../libs/zbxsysinfo/libzbxsysinfo.a(common.o)(.text+0x1377): In function `forward_request':
common/common.c:1328: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../libs/zbxsysinfo/libzbxsysinfo.a(common.o)(.text+0x2326): In function `CHECK_DNS':
: undefined reference to `__res_query'
collect2: ld returned 1 exit status
make[3]: *** [zabbix_agent] Error 1


1. doesn't requirement to have the same glibc libraries eliminate the reason to compile static binaries at all ?

2. what causes "undefined reference to `__res_query'" ?

chocho63
19-10-2005, 17:02
I've had the same problem with 1.1 Beta 1 or 1.1 Beta 2 and gcc 3.2.3

richlv
19-10-2005, 17:11
hmm, interesting... turns out i have downloaded archive containing beta2, but page footer in php webinterface says beta1. go figure :)

probably version number was not updated in some places.

leoh
25-10-2005, 02:38
same problem running knnopix.

../libs/zbxsysinfo/libzbxsysinfo.a(common.o)(.text+0x14d6): In function `forward_request':
common/common.c:1328: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../libs/zbxsysinfo/libzbxsysinfo.a(common.o)(.text+0x262a): In function `CHECK_DNS':
common/common.c:1970: undefined reference to `__res_query'
collect2: ld returned 1 exit status
make[3]: *** [zabbix_agent] Error 1
make[3]: Leaving directory `/var/tmp/zabbix-1.1beta2/src/zabbix_agent'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/var/tmp/zabbix-1.1beta2/src/zabbix_agent'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/zabbix-1.1beta2/src'
make: *** [all-recursive] Error 1

James Wells
25-10-2005, 03:21
Greetings,

Right off the bat, it looks like you need to locate libnss.a and add it to the gcc command line. libnss provides __res_query and a lot of the other name lookup routines.

richlv
28-10-2005, 12:59
Right off the bat, it looks like you need to locate libnss.a and add it to the gcc command line. libnss provides __res_query and a lot of the other name lookup routines.

well, my slackware box did not have them, so i looked for some additional information.

"Or, you can rebuild glibc with --enable-static-nss then you will have libnss_*.a files".

this seems too much for a simple agent building...

and what about these warnings : "warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking" ? will these binaries really require the same glibc version ?

has anybody successfully compiled static agents for latest zabbix beta versions ?

rushowr
20-12-2005, 09:10
if anyone has, please let me know. I'm at a hardcore standstill on this one

richlv
20-12-2005, 09:18
well, unfortunately i still get the same problem with 1.1.beta4...

matt_voss
02-01-2006, 23:57
After running ./configure edit the file src/zabbix_agent/Makefile

On these lines append /usr/lib/libresolv.a (FYI libresolv.a is part of the glibc-devel package).

zabbix_agent_LDADD = ../libs/zbxsysinfo/libzbxsysinfo.a ../libs/zbxsysinfo/linux/libzbxsysinfo2.a \
../libs/zbxlog/libzbxlog.a \
../libs/zbxcrypto/libzbxcrypto.a ../libs/zbxnet/libzbxnet.a ../libs/zbxconf/libzbxconf.a \
../libs/zbxcommon/libzbxcommon.a /usr/lib/libresolv.a

zabbix_agentd_LDADD = ../libs/zbxsysinfo/libzbxsysinfo.a ../libs/zbxsysinfo/linux/libzbxsysinfo2.a ../libs/zbxlog/libzbxlog.a ../libs/zbxcrypto/libzbxcrypto.a \
../libs/zbxpid/libzbxpid.a ../libs/zbxnet/libzbxnet.a ../libs/zbxconf/libzbxconf.a \
../libs/zbxcommon/libzbxcommon.a /usr/lib/libresolv.a

cybermage
03-01-2006, 18:40
Reporting same problem in 1.1b5.

jean
28-04-2006, 16:06
Hello,

I have the same problem with the beta 9, someone has find a solution ?

Regards

Jean

BrianC
23-05-2006, 19:26
Matt's fix worked for me on beta10, but I had to make the same change in src/zabbix_sender/Makefile as well.

It still threw a warning error on 'gethostbyname', but the compile completed.

-B