I'm trying to use node-phash
in an aws lambda
function, but coming-up short.
I've found instructions for the node-canvas
library here and on github, but still having some trouble.
Steps I've taken:
- on an Amazon Linux ec2 instance, I've cloned the
node-phash
repo I set an env var to use an
rpath
, as thenode-canvas
walkthrough instructed:export LDFLAGS=-Wl,-rpath=/var/task/
I determined the shared deps:
$ readelf -d pHashBinding.node | grep NEEDED 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6] 0x0000000000000001 (NEEDED) Shared library: [libm.so.6] 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
I then copied and downloaded the listed files to include in my
zip
forlambda
- I ran
npm install
, which went ostensibly fine I confirmed that the
.node
would look at theaws lambda
root for its deps:$ objdump -p build/Release/pHashBinding.node | grep RPATH RPATH /var/task/
I then downloaded the
build/Release
folder and overwrote my project'snode_modules/phash/build/Release
with the folder from the Amazon Linux environment- I zipped my project for upload to
Lambda
, including the 5*.o
files from step 3 into the root of the zip, so they'd be unzipped at/var/task/
inLambda
Unfortunately, after all that, I still get the same errors I did before:
"errorMessage": "/usr/local/lib64/node-v4.3.x/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /var/task/node_modules/node-phash/build/Release/pHashBinding.node)",
"errorType": "Error",
"stackTrace": [
"Object.Module._extensions..node (module.js:434:18)",
"Module.load (module.js:343:32)",
"Function.Module._load (module.js:300:12)",
"Module.require (module.js:353:17)",
"require (internal/module.js:12:17)",
"Object.<anonymous> (/var/task/node_modules/node-phash/lib/phash.js:23:13)",
"Module._compile (module.js:409:26)",
"Object.Module._extensions..js (module.js:416:10)",
"Module.load (module.js:343:32)"
]
}
libstdc++.so.6
is in the root of my zip
. So, how do I get pHashBinding.node
to reference the correct directory when looking for dependencies?