aws-lambda-go: /lib64/libc.so.6: version `GLIBC_2.32' not found when building on linux
I was running into this error when I followed the instructions in the README:
/var/task/main: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/main)
I managed to fix it via by setting CGO_ENABLED=0 when building on linux, similar to the instructions for windows, ie
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main main.go
Should that be included in the README, or is there a better way to fix this?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 76
- Comments: 29
Commits related to this issue
- include the other env-vars too mentioned here https://github.com/aws/aws-lambda-go/issues/340 — committed to philippkueng/pod-babashka-go-sqlite3 by philippkueng 4 years ago
- Disable Cgo - see issue https://github.com/aws/aws-lambda-go/issues/340 — committed to clowa/lambda-golang-redirect by clowa 4 years ago
- https://github.com/aws/aws-lambda-go/issues/340 fixed by adding CGO enabled — committed to BlitzBudget/serverless-backend-application by NagarjunNagesh 3 years ago
- Merge pull request #66 from BlitzBudget/develop https://github.com/aws/aws-lambda-go/issues/340 fixed by adding CGO e… — committed to BlitzBudget/serverless-backend-application by NagarjunNagesh 3 years ago
- Fix issue with GLIBC_2.32 not found Build with `CGO_ENABLED=0` https://github.com/aws/aws-lambda-go/issues/340 — committed to conradhodge/next-tram by conradhodge 3 years ago
- Fix issue with GLIBC_2.32 not found Build with `CGO_ENABLED=0` https://github.com/aws/aws-lambda-go/issues/340 — committed to conradhodge/next-tram by conradhodge 3 years ago
I ran into this while using the SAM CLI.
The fix was ultimately the suggestion to use
CGO_ENABLED=0but I had to take some additional steps to make this work with sam, see https://github.com/aws/aws-sam-cli/issues/3894 for the breadcrumbs.Documented the approach for my project here: https://www.gaunt.dev/blog/2022/glibc-error-with-aws-sam-and-go/
Hello? 3 years passed and still not resolved?
Affected by the same issue. Trying to use SQLite with go on lambda is painful.
As an FYI since it has not been posted in this thread.
Amazon Linux 2023 provides glibc 2.34, upgrade to al2023 and latest Go.
Amazon doesn’t care about open source
@gauntface that will only work if your project does not depend on cgo. In my (and others here) case, I required cgo for
go-sqlite3, which requires special compilation specifically for the Lambda Go runtime environment.This was absolutely terrifying to discover last minute. I recently switched all 4 of my PCs from Ubuntu to Manjaro and right as I was deploying some new code this issue popped up. I’m extremely lucky all I had to do was add
CGO_ENABLED=0to the build flags to fix it but this is a last minute dependency I didn’t even know existed in my build pipeline.I have no idea why Manjaro needs a new build flag versus Ubuntu unfortunately - that’s definitely not an area of expertise for me.
And people don’t appear to read the FIRST POST at the top that literally tells you how to solve it. This is a common Linux building issue.
Finally got it working but my process of trial and error doesnt seem that elegant. It works with this image:
public.ecr.aws/lambda/go:1.2022.11.03.18which installedglibc-devel-2.17-324.189.amzn1.x86_64as part of the golang install.Open to suggestions\advice on why this is happening or anything i can do to improve it. Thanks.
I ended up building and deploying from cloudshell. Had to move the GOPATH to outside of the home directory. I still haven’t fully understood what lambda is doing with it.
I have witnessed this one today, seems like it is just a problem of using CGO when the C library you have under the hood is not compatible with glibc 2.32 or there is no C library but you are trying to build with CGO, therefore, it can not detect/find the correct version for .so files. It took the production down for 1 hour, just because of CGO_ENABLED=1
CGO should never be used and it should be avoided as much as possible just like the reflection
https://dave.cheney.net/2016/01/18/cgo-is-not-go