I had this project that runs in aws lambda. It compiled and worked fine until I decided to enhance this project with a library (https://github.com/zaf/resample) 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.
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: libsoxr.so.0: 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.
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.