AWS Lambda - Unable to load DLL Magick.NET-Q8-x64.Native.dll
See original GitHub issueI’m trying to use Amazons Lambda service to do some image processing. Lambda is essentially serverless* code execution. (*there is a server, its just not one you run or pay to run 24/7). The way it works, you write some code, publish and upload it then lambda can execute it. Lambda runs on Amazon Linux which is Red Hat/CentOS.
I’ve read the crossplatform information over here and I did have the initial problem of ‘not found’ for libMagickCore-7.Q8.so.3, libMagickWand-7.Q8.so.3 and libjpeg.so.8. On a seperate amazon linux instance I compiled libjpeg and followed the instructions on how to compile ImageMagick so I have all the .so files I was missing.
As I am using C# in lambda it means I am targeting the netcoreapp1.0 framework which from what I understand is compatible with .NET Standard 1.3.
All my .so files are in the /lib of my published project and as per the lambda docs is where LD_LIBRARY_PATH points to.
I created a sample function which executes ldd on my .so files.
private string LDDFile(string file)
{
var process = new System.Diagnostics.Process()
{
StartInfo = new System.Diagnostics.ProcessStartInfo
{
FileName = "ldd",
Arguments = file,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};
process.Start();
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return result;
}
and then from the lambda logs I can see the result of libjpeg.so.8, libMagickCore-7.Q8.so.3, libMagickWand-7.Q8.so.3 and Magick.NET-Q8-x64.Native.dll.so.
lib/libjpeg.so.8: linux-vdso.so.1 => (0x00007ffe1abfa000) libc.so.6 => /lib64/libc.so.6 (0x00007f474770d000) /lib64/ld-linux-x86-64.so.2 (0x0000555b1d6f4000)
lib/libMagickWand-7.Q8.so.3: linux-vdso.so.1 => (0x00007fffb23f6000) libMagickCore-7.Q8.so.3 => /var/task/lib/libMagickCore-7.Q8.so.3 (0x00007fa9166db000) libjpeg.so.8 => /var/task/lib/libjpeg.so.8 (0x00007fa9164a0000) libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x00007fa91627a000) liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007fa916056000) libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007fa915ced000) libz.so.1 => /lib64/libz.so.1 (0x00007fa915ad7000) libgomp.so.1 => /usr/lib64/libgomp.so.1 (0x00007fa9158c1000) libm.so.6 => /lib64/libm.so.6 (0x00007fa9155be000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fa9153a8000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa91518c000) libc.so.6 => /lib64/libc.so.6 (0x00007fa914dc9000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fa914bc5000) /lib64/ld-linux-x86-64.so.2 (0x0000557987925000)
lib/libMagickCore-7.Q8.so.3: linux-vdso.so.1 => (0x00007ffc4ebcb000) libjpeg.so.8 => /var/task/lib/libjpeg.so.8 (0x00007f2ab8701000) libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x00007f2ab84da000) liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007f2ab82b6000) libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007f2ab7f4e000) libz.so.1 => /lib64/libz.so.1 (0x00007f2ab7d37000) libm.so.6 => /lib64/libm.so.6 (0x00007f2ab7a35000) libgomp.so.1 => /usr/lib64/libgomp.so.1 (0x00007f2ab781f000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2ab7608000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2ab73ec000) libc.so.6 => /lib64/libc.so.6 (0x00007f2ab702a000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f2ab6e25000) /lib64/ld-linux-x86-64.so.2 (0x0000555ac3db1000)
lib/Magick.NET-Q8-x64.Native.dll.so: linux-vdso.so.1 => (0x00007fffe9eaa000) libMagickCore-7.Q8.so.3 => /var/task/lib/libMagickCore-7.Q8.so.3 (0x00007f07668ad000) libMagickWand-7.Q8.so.3 => /var/task/lib/libMagickWand-7.Q8.so.3 (0x00007f07665a7000) libjpeg.so.8 => /var/task/lib/libjpeg.so.8 (0x00007f076636d000) libm.so.6 => /lib64/libm.so.6 (0x00007f076606b000) libc.so.6 => /lib64/libc.so.6 (0x00007f0765ca8000) libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x00007f0765a82000) liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007f076585e000) libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007f07654f5000) libz.so.1 => /lib64/libz.so.1 (0x00007f07652df000) libgomp.so.1 => /usr/lib64/libgomp.so.1 (0x00007f07650c9000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f0764eb2000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f0764c96000) /lib64/ld-linux-x86-64.so.2 (0x000055bf0a4bd000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f0764a91000)
And for good measure I also tried where the Magick.NET-Q8-x64.Native.dll.so ends up in teh runtime folder.
runtimes/linux-x64/native/Magick.NET-Q8-x64.Native.dll.so: linux-vdso.so.1 => (0x00007ffda2aab000) libMagickCore-7.Q8.so.3 => /var/task/lib/libMagickCore-7.Q8.so.3 (0x00007fb5ff125000) libMagickWand-7.Q8.so.3 => /var/task/lib/libMagickWand-7.Q8.so.3 (0x00007fb5fee1f000) libjpeg.so.8 => /var/task/lib/libjpeg.so.8 (0x00007fb5febe5000) libm.so.6 => /lib64/libm.so.6 (0x00007fb5fe8e3000) libc.so.6 => /lib64/libc.so.6 (0x00007fb5fe520000) libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x00007fb5fe2fa000) liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007fb5fe0d6000) libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007fb5fdd6d000) libz.so.1 => /lib64/libz.so.1 (0x00007fb5fdb57000) libgomp.so.1 => /usr/lib64/libgomp.so.1 (0x00007fb5fd941000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fb5fd72a000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb5fd50e000) /lib64/ld-linux-x86-64.so.2 (0x0000557c5516c000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fb5fd309000)
As far as I can see everything seems fine, although there was this warning which may be very important that I just remembered that I’m going to go look at now.
ldd: warning: you do not have execution permission for `lib/Magick.NET-Q8-x64.Native.dll.so’
I’ve even tried with this Native.dll.so in the root published directory but nothing seems to work.
Any suggestions of what else I can try?
EDIT: So Magick.NET-Q8-x64.Native.dll.so does not have the execute bit set, chmod +x gets rid of that above warning but code still does not execute. I’ve tried with this file in /, /lib and where it originally lives, /runtimes/linux-x64/native.
The code I am trying to execute at the moment is just
var magickImage = new MagickImage(MagickColors.Red, 100, 100);
logger?.Log($"Image size: {magickImage.Width}x{magickImage.Height}");
EDIT2: I have attached 2 zips (source and published) for testing. In AWS the handler/entry point is LambdaImageMagickTest::LambdaImageMagickTest.Program::MyHandler
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
I’m seeing this error in a Windows Server 2012 environment when reaching the line of code in which I create a MagickImage from a byte[]. I’m using the latest NuGet package. I suspect it’s related to coder delegates elsewhere mentioned as potentially not threadsafe.
Hi @dlemstra, I am still getting error on AWS Lambda. I am using Net 6 with Magick.net. I tried the various options and suggestions on various linux/lambda related configurations. Is there some suggestions/document I can use? I am trying both docker image as well as zip option for lambda