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: open
- Created 4 years ago
- Reactions: 65
- Comments: 28
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 2 years ago
- Disable Cgo - see issue https://github.com/aws/aws-lambda-go/issues/340 — committed to clowa/lambda-golang-redirect by clowa a year ago
- https://github.com/aws/aws-lambda-go/issues/340 fixed by adding CGO enabled — committed to BlitzBudget/serverless-backend-application by NagarjunNagesh a year 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 a year 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/
Affected by the same issue. Trying to use SQLite with go on lambda is painful.
Hello? 3 years passed and still not resolved?
Now it’s working, thanks a lot. I think it’s due to cache issues, after remove the funcation and rebuild , it’s woking now.
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.
@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.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.
Amazon doesn’t care about open source
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.