#734·gopacket

How to package libraries 'libpcap' into go programs? error while loading shared libraries: libpcap.so.0.8.

Author: azureskyLCreated Dec 3, 2019Updated Jun 5, 2025

my go program import gopacket, I use go build -o main main.go to build program, system is Ubuntu 18.04.3 LTS with go version go1.13.1 linux/amd64. when I run the linux executeable program main in CentOS Release 6.10 (Final) Kernel Linux 2.6.32-754.el6.x86_64, which does install go enveriment, it report an error:

[root@localhost Desktop]# ./main ./main: error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory

because CentOS doesn't containlibpcap, my goal is to run go program on the CentOS which dosen't hava libpcap or go enveriment. Is there any way to package libraries 'libpcap' into go programs? How ?