[SOLVED] Problem with static libs (CGO_ENABLED=0 don't work?)

Helloguys :slight_smile:

First, I’m sorry if it’s a simple configuration problem or something like that, I’m beginner dev. :laughing:

I need help because I can’t use static libs.
I compile my code and execute the bin file on an other computer (without go installed, obviously) but i have an error “error while loading shared libraries: libgo.so.14: cannot open shared object file: No such file or directory”
So, after somes searchs on google I find the CGO_ENABLED env var need to be changed to “0” for switch to static libs, but don’t work for me :cry:

My go env:
>> [jordan@jmaster] {11:52:47} ~$ go env
GOARCH=“amd64”
GOBIN=“”
GOCACHE=“/home/jordan/.cache/go-build”
GOEXE=“”
GOFLAGS=“”
GOHOSTARCH=“amd64”
GOHOSTOS=“linux”
GOOS=“linux”
GOPATH=“/home/jordan/go”
GOPROXY=“”
GORACE=“”
GOROOT=“/usr”
GOTMPDIR=“”
GOTOOLDIR=“/usr/libexec/gcc/x86_64-redhat-linux/9”
GCCGO=“/usr/bin/gccgo”
CC=“gcc”
CXX=“g++”
CGO_ENABLED=“0”
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-build185346707=/tmp/go-build -gno-record-gcc-switches -funwind-tables”

My go version:
>> [jordan@jmaster] {11:53:16} ~$ go version
go version go1.12.2 gccgo (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1) linux/amd64

When i compile my code :
>> [jordan@jmaster] {11:56:23} /var/opt/development/golang/test$ ls
main.go
>> [jordan@jmaster] {11:56:24} /var/opt/development/golang/test$ go build -a -o app
>> [jordan@jmaster] {11:56:31} /var/opt/development/golang/test$ ldd app

  • linux-vdso.so.1 (0x00007ffdcfdca000)*
  • libgo.so.14 => /lib64/libgo.so.14 (0x00007f599cef2000)*
  • libm.so.6 => /lib64/libm.so.6 (0x00007f599cdac000)*
  • libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f599cd92000)*
  • libc.so.6 => /lib64/libc.so.6 (0x00007f599cbcc000)*
  • /lib64/ld-linux-x86-64.so.2 (0x00007f599e5f5000)*

My expected result:

ldd on app return “is not a dynamic executable”

Thanks for help :slight_smile:

1 Like

Solved after sooooo much try …

Fedora up-to-date go version is 1.12.2.
I have just remove that yum version and install tar.gz last version on go website (v1.13.3).
Tadaaaaa’ that work… :upside_down_face:

>> [jordan@jmaster] {21:06:55} /var/opt/development/golang/save$ go version
go version go1.13.3 linux/amd64
>> [jordan@jmaster] {21:07:00} /var/opt/development/golang/save$ ls
main.go
>> [jordan@jmaster] {21:07:06} /var/opt/development/golang/save$ go build -a -o app
>> [jordan@jmaster] {21:07:18} /var/opt/development/golang/save$ ldd app

  •    not a dynamic executable*
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.