Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to statically package dynamic link libraries into programs ? #35942

Closed
azureskyL opened this issue Dec 3, 2019 · 1 comment
Closed

How to statically package dynamic link libraries into programs ? #35942

azureskyL opened this issue Dec 3, 2019 · 1 comment

Comments

@azureskyL
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.13.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zxcasd/.cache/go-build"
GOENV="/home/zxcasd/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zxcasd/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build906863287=/tmp/go-build -gno-record-gcc-switches"

What did you do?

my program import google/gopacket, and I use go build -o main main.go to build go program in Ubuntu 18.04.3 LTS .
Then 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,

What did you expect to see?

the go program main can run normally.

What did you see instead?

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 does not include the library libpcap, but Ubuntu 18.04 includes, while the program main is linked to libpcap.

$ ldd main
linux-vdso.so.1 (0x00007ffe505ad000)
libpcap.so.0.8 => /usr/lib/x86_64-linux-gnu/libpcap.so.0.8 (0x00007f3cb870e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3cb84ef000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3cb80fe000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3cb894f000)

my goal is to run go program on the CentOS which dosen't include libpcap.
Is there any way to statically package libraries 'libpcap' into go programs? How ?
could anyone help me ?

@ianlancetaylor
Copy link
Contributor

Unlike other projects, we do not use the issue tracker for questions such as these. It is only used for bugs and feature proposals. I will close this issue, but please feel free to ask it in any of these forums below:

Thanks

@golang golang locked and limited conversation to collaborators Dec 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants