Libc.so.6 could not be found

I get the error below when I run a Go executable on one machine, when compiled using 1.15.5, but it works fine when using 1.14.12. This confuses me, I thought that go executables where statically linked an did not have any dependencies?

./softtube.download: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32’ not found (required by ./softtube.download)

The machine I am compiling on runs Manjaro Cinnamon, and the computer where the problem occurs runs Linux Mint 20.

What is it that I am not understanding here? Are go executables not “independent”?

I think there are some things in Go that use libc like the net and os/user packages (I think that’s one of the reasons that the race detector doesn’t work when you use the net package). If you’re not using these packages, then your program can be statically compiled, or there might be some compile-time options to use pure-Go versions of these packages. I’m still reading through some of the bug reports about it like this one.

From what I can see, I am not using net or os/user in this particular executable.

When you are saying “can be compiled statically”, does that mean that I need to add an argument to my go build statement to make it compile statically?

pure-Go?

Based on what I’m seeing in softtube.download, you reference internal/softtube.core and that references github.com/go-sql-driver/mysql which uses the net package.

1 Like

And I’ll admit that I don’t really know a lot about static vs. dynamic linking, but it’s my understanding is the net package uses cgo to handle some of the calls to the operating system (I believe, for example, resolving hostnames to IP addresses lookup) and that it does so through libc.

EDIT: Also, regarding the options, I think you could disable cgo by setting CGO_ENABLED=0 before your go build command. I *think* cgo is the only place you get dynamic linking that you have to explicitly opt out of.

Obviously I am not very good at reading my own code :slight_smile:

Thanks!

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