Ad Widget

Collapse

problem with --enable-static

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #1

    problem with --enable-static

    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'" ?
    Zabbix 3.0 Network Monitoring book
  • chocho63
    Member
    • Jun 2005
    • 53

    #2
    Same problem

    I've had the same problem with 1.1 Beta 1 or 1.1 Beta 2 and gcc 3.2.3

    Comment

    • richlv
      Senior Member
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Oct 2005
      • 3112

      #3
      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.
      Zabbix 3.0 Network Monitoring book

      Comment

      • leoh
        Member
        • Oct 2005
        • 47

        #4
        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

        Comment

        • James Wells
          Senior Member
          • Jun 2005
          • 664

          #5
          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.
          Unofficial Zabbix Developer

          Comment

          • richlv
            Senior Member
            Zabbix Certified Trainer
            Zabbix Certified SpecialistZabbix Certified Professional
            • Oct 2005
            • 3112

            #6
            Originally posted by James Wells
            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 ?
            Zabbix 3.0 Network Monitoring book

            Comment

            • rushowr
              Member
              • Jul 2005
              • 30

              #7
              if anyone has, please let me know. I'm at a hardcore standstill on this one

              Comment

              • richlv
                Senior Member
                Zabbix Certified Trainer
                Zabbix Certified SpecialistZabbix Certified Professional
                • Oct 2005
                • 3112

                #8
                well, unfortunately i still get the same problem with 1.1.beta4...
                Zabbix 3.0 Network Monitoring book

                Comment

                • matt_voss
                  Junior Member
                  • Dec 2005
                  • 4

                  #9
                  Possible Solution

                  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

                  Comment

                  • cybermage
                    Junior Member
                    • Oct 2005
                    • 12

                    #10
                    Reporting same problem in 1.1b5.

                    Comment

                    • jean
                      Member
                      • Apr 2006
                      • 85

                      #11
                      Same error with beta 9

                      Hello,

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

                      Regards

                      Jean

                      Comment

                      • BrianC
                        Junior Member
                        • May 2006
                        • 8

                        #12
                        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

                        Comment

                        Working...