question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lambda: can't install with static libvips

See original GitHub issue

I need to compile libvips since the bundled one with sharp doesn’t support bmp, and I want to run this inside aws lambda so I am compiling libvips as a static library. This is done in the amazonlinux docker container.

I ran into 2 problems.

  1. During npm install
bash-4.2# PKG_CONFIG_PATH=~/vips/lib/pkgconfig/ npm install --runtime_link=static -prefix=~/sharp_test --unsafe-perm sharp
-
> sharp@0.17.1 install /root/sharp_test/node_modules/sharp
> node-gyp rebuild

readelf: Error: '/root/vips/lib/libvips-cpp.so': No such file
gyp: Call to 'if readelf -Ws "$(PKG_CONFIG_PATH=":$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --variable libdir vips-cpp)/libvips-cpp.so" | c++filt | grep -qF __cxx11;then echo "1";else echo "0";fi' returned exit status 0 while in binding.gyp. while trying to load binding.gyp

These are the flags I used to install vips ./configure --enable-static --disable-shared --prefix=$HOME/vips I got around this by removing --disable-shared Does sharp really need both shared and static libraries of libvips?

  1. After that I got another error during npm install
bash-4.2# PKG_CONFIG_PATH=~/vips/lib/pkgconfig/ npm install --runtime_link=static -prefix=~/sharp_test --unsafe-perm sharp
-
> sharp@0.17.1 install /root/sharp_test/node_modules/sharp
> node-gyp rebuild

make: Entering directory `/root/sharp_test/node_modules/sharp/build'
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
  CXX(target) Release/obj.target/sharp/src/metadata.o
  CXX(target) Release/obj.target/sharp/src/operations.o
  CXX(target) Release/obj.target/sharp/src/pipeline.o
  CXX(target) Release/obj.target/sharp/src/sharp.o
  CXX(target) Release/obj.target/sharp/src/utilities.o
  SOLINK_MODULE(target) Release/obj.target/sharp.node
/usr/bin/ld: cannot find -ljbig
/usr/bin/ld: cannot find -lffi
collect2: error: ld returned 1 exit status
make: *** [Release/obj.target/sharp.node] Error 1
make: Leaving directory `/root/sharp_test/node_modules/sharp/build'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kevinchncommented, Feb 4, 2017

I got it working locally with shared libraries, but I’m getting an error when it runs on AWS lambda

module initialization error: Error
at Error (native)
at Object.Module._extensions..node (module.js:434:18)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:8:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/task/node_modules/sharp/lib/index.js:3:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)

Which looks like something inside build/Release/sharp.node I’m not really sure what this means. Any ideas?

Nevermind, AWS didn’t show the specific error for some reason. I had to use the “Test” button to see it. It seems like libwebp and libexif couldn’t be found even though Amazon listed them in the list of packages (https://aws.amazon.com/amazon-linux-ami/2016.03-packages/). I added those inside my zip and it works now. Thanks!

0reactions
ismailqaucommented, Nov 7, 2018

Worked for me:

  1. Build and installed normally (with libpoppler support)
  2. copied libvips.so.42 and libvips-cpp.so.42 from /usr/local/lib/ to /usr/lib/
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sharp on AWS Amplify Backend Lambda Causing Build to Fail
When I push to git to trigger a deploy, my build is failing I think due to vips/vips8 a sharp dependency not being...
Read more >
Creating Lambda container images - AWS Documentation
Create a container image for a Lambda function by using an AWS provided base image or an alternative base image.
Read more >
AWS Lambda Microservice Workshop using S3, Libvips, & Ruby
Interested in learning AWS & Lambda from the ground up using Ruby? This workshop leverages Docker & AWS SAM Cookiecutter templates to ...
Read more >
terraform-aws-modules/lambda/aws
Build and install dependencies - read more. ... Create static and dynamic aliases for AWS Lambda Function - see usage, see modules/alias.
Read more >
libvips Executable for AWS Lambda | Cloud Functions library
libvips -lambda does not have a standard license declared. Check the repository for any ... libvips-lambda releases are available to install and integrate....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found