Problem making a static build with C library


I had this project that runs in aws lambda. It compiled and worked fine until I decided to enhance this project with a library ( that requires a C library, libsoxr. I read a lot about this and it seems people have had success bundling everything together with a static build.

After having some initial problems compiling it on my mac with GOOS=linux, someone in IRC said I should compile it on an actual Amazon Linux distro, since that’s exactly what lambda runs on.

I set up an Amazon Linux VM. I compiled libsoxr with a custom build that outputs .a instead of just .so files. But I don’t really know what my go Makefile should look like. I’ve been trying variations of things I’ve found on the internet but nothing seems to completely work. Here’s a pastebin of two variations and their associated errors.

I’ve googled endlessly but can’t really make heads or tails of what’s happening / what needs to happen. If anyone has any direction or advice, I’d really appreciate it.

Maybe this could be of use?

Package up your application with the .so dependency and deploy?

So if I modify my make file to be GOOS=linux go build -a -o bin/mixer mixer/*.go and build and ship… I get this when running the lambda: /var/task/bin/mixer: error while loading shared libraries: cannot open shared object file: No such file or directory The zip file that’s shipped only has the main binary and not any dynamic libraries.

So I zipped up the binary and those files until it looked like this and deployed.

Now I get a new error:
fork/exec /var/task/bin/mixer: no such file or directory: PathError null

Not sure if that’s good or not. I’ll investigate more soon

Actually, I woke up with a fresh mind and discovered the obvious error here… The actual app ‘mixer’ has to be in /bin. I reformulated the archive with that structure and it appears to be working.

1 Like

Good to hear its working for you

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