Ad Widget

Collapse

How to build agent2 with statically linked libraries?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • onlybee
    Junior Member
    • Mar 2021
    • 7

    #1

    How to build agent2 with statically linked libraries?

    I am trying to build zabbix agent2 with statically linked libraries, which I can distribute among different servers. However, when I started agent2 in a different server without related libraries, it still asked for required libraries, while the zabbix_agentd compiled together work well.
    Click image for larger version

Name:	screen.PNG
Views:	1020
Size:	31.2 KB
ID:	420472
    The error information when start agent2 is as following:
    ./zabbix_agent2: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

    The configure code is:
    ./configure --prefix=/home/zabbix --enable-agent --with-openssl --with-libpcre --enable-ipv6 --enable-agent2 --enable-static

    The configure result is:
    Click image for larger version

Name:	screen.PNG
Views:	1001
Size:	33.2 KB
ID:	420473

    I'd really like to attach my Makefile generated here,but I has no permission to upload file now in this forum.

    Can any one give me a hand? Is there anything I did wrong or dose zabbix agent2 not support compile statically?
  • onlybee
    Junior Member
    • Mar 2021
    • 7

    #2
    Finally I managed it.
    This is how I get it work.

    First, configure it with command: ./configure --prefix=/home/zabbix --enable-agent --with-openssl --with-libpcre --enable-ipv6 --enable-agent2 --enable-static

    Then, edit the Makefile generated for agent2 src/go/Makefile, add -extldflags=-static to -ldflags for go build and go install as following:
    Click image for larger version  Name:	screen.PNG Views:	0 Size:	25.1 KB ID:	420543
    Now make and make install and we will get the agent2 compiled with statically lined libraries.
    Last edited by onlybee; 12-03-2021, 03:46.

    Comment

    • onlybee
      Junior Member
      • Mar 2021
      • 7

      #3
      I'm using zabbix 5.0.5 by the way.

      Comment

      Working...