Closed ITaluone closed 3 years ago
Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.
Hey I got this error when hosted on Linux server . It works fine on my windows machine but when I host to linux serve I get above error help please
@ramson12 Have you checked if you have all the dependencies installed?
Can you please help me how I can install dependencies Thank you
@ramson12 The easiest is to install the wkhtmltopdf package, the WkHtmlToPdf-DotNet is just a wrapper around the native library.
@HakanL i have only added Haukcode.WkHtmlToPdfDotNet from Nuget manager.
@ramson12 I understand that, but this is just a wrapper for the native library wkhtmltopdf, you need to make sure your platform has all the necessary dependencies for the wkhtmltopdf library, this NuGet package can't do that for you.
it worked for me after registering the runtimes.
after 5 hours of debugging and testing, I checked, and during the installation, it didn't register the Runtimes. I added the following command in Docker and it worked 100%
ldconfig -p | grep 'libwkhtml' /usr/local/lib/runtimes/libwkhtmltox.so libwkhtmltox.so
after that it worked normally
@DanielBruch I wonder if that just bypassed the logic that tries to find the runtime, it shouldn't be necessary to do that step, so it's more of a workaround. I wonder if this may be related to #72, maybe you can try the new 1.5.71 NuGet package, maybe that fix helps this scenario as well?
@HakanL
apologies for the delay. I tested it again on another Server on Ubuntu 18.04 and it had the same errors. lack of libjpeg62
and Current platform is not supported.
Even installing libjpeg62
it didn't show resolution
I downloaded the SO File from https://wkhtmltopdf.org/downloads.html and declared SO as in the above comment.
ldconfig -p | grep 'libwkhtml' /usr/local/lib/runtimes/libwkhtmltox.so libwkhtmltox.so
After declaring the SO, it worked perfectly
Edited: I tested in version 1.5.71 as you requested
Thanks for testing Daniel, I haven't heard of anyone else having to register the native library. You don't happen to have this testable in a docker container do you? Without that it's hard to know if it's something related to your Ubuntu instance.
Hi I am using .NET core Azure functions app getting the error mentioned above.
"One or more errors occurred. (Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.)". See the function execution logs for additional details.". See the function execution logs for additional details."
(Inner Exception #0) System.NotSupportedException: Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.
[2022-05-06T17:08:27.778Z] at WkHtmlToPdfDotNet.ModuleFactory.GetModule()
[2022-05-06T17:08:27.781Z] at WkHtmlToPdfDotNet.PdfTools.Load()
[2022-05-06T17:08:27.784Z] at WkHtmlToPdfDotNet.BasicConverter.Convert(IDocument document)
[2022-05-06T17:08:27.788Z] at WkHtmlToPdfDotNet.SynchronizedConverter.<>c__DisplayClass4_0.
Which solutions actualy solves this problem ? Can you please guide step by step. This in local environment, but the same issue occures in the server as well.
@saumyeN Most likely you're missing some native dependency, try to install the native library and see what it installs. Could also be that it doesn't work with native libraries in Azure consumption plan.
Can you suggest where I can get the native library ? And how to install it ?
Can you suggest where I can get the native library ? And how to install it ?
You'll find all the details on their project page: https://wkhtmltopdf.org/
In my case that I was using AWS and Centos 7 I had to follow this steps
1- install: libgdiplus-2.10-10.el7.x86_64 2- Add the files libwkhtmltox (with extensions .dll, .dylib, .so) and set their Compile Action as Content and Copy directory as: Always
With that everything wired up now is working perfectly.
You shouldn't have to add the native binaries manually, they should be added during the build.
I'm having trouble implementing this library on Amazon Linux 2. I always get this message and I don't know what might be missing:
"Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported."
FROM public.ecr.aws/lambda/dotnet:7
WORKDIR /var/task
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y \
fontconfig \
wget \
libX11 \
libXext \
libXrender \
libjpeg \
openssl \
xorg-x11-fonts-75dpi \
xorg-x11-fonts-Type1 \
libgdiplus \
ca-certificates \
zlib-devel
RUN rpm -Uvh https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm
RUN mkdir /opt/lib
RUN ln -s /usr/local/lib/libwkhtmltox.so /usr/lib/libwkhtmltox.so
RUN ln -s /usr/local/lib/libwkhtmltox.so /opt/lib/libwkhtmltox.so
COPY "bin/Release/lambda-publish" .
You're missing some native dependencies. Try to install/load the native library wkhtmltopdf and once you got that working this wrapper should be fine.
For anyone using AWS Toolkit for Visual Studio and having the same problem, I noticed that for some reason the "libwkhtmltox.so" binary is not copied to "runtimes/linux-x64/native/" so basically you have to create a COPY once installed.
FROM public.ecr.aws/lambda/dotnet:7
WORKDIR /var/task
RUN yum install -y \
libX11 \
libXext \
libXrender \
libjpeg \
openssl \
xorg-x11-fonts-75dpi \
xorg-x11-fonts-Type1 \
&& rpm -U https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm \
&& mkdir -p ./runtimes/linux-x64/native \
&& cp /usr/local/lib/libwkhtmltox.so ./runtimes/linux-x64/native/libwkhtmltox.so \
&& rpm -e wkhtmltox-0.12.6-1.amazonlinux2.x86_64
COPY "bin/Release/lambda-publish" .
@rmalca So you shouldn't actually install the native library, it's already part of this wrapper, I was just suggesting it as a way to determine which dependencies are required. It may work but your image will be larger than necessary.
@rmalca So you shouldn't actually install the native library, it's already part of this wrapper, I was just suggesting it as a way to determine which dependencies are required. It may work but your image will be larger than necessary.
Got it, I made a change to my Dockerfile reducing the image size by 79MB. I must include the native library installation as the "libwkhtmltox.so" file is not being copied at publish time via the AWS Toolkit.
@rmalca - are you able to fix the issue. is it working now?
I am also facing same error when deployed in aws lambda as image. I noticed that file libwkhtmltox in ./runtimes/linux-x64/native is not being picked by code and throwing the similar error. I have added x86 path also. then it worked.
Added below lines in docker RUN mkdir -p ./runtimes/linux-x86/native \ && cp /usr/local/lib/libwkhtmltox.so ./runtimes/linux-x86/native/libwkhtmltox.so
I am not sure whether this is the right way to do it or not. but it worked.
The publish should copy the native files, if not then that part should be troubleshooted. Copying the file is a workaround, which may be okay until the publish has been figured out.
Can we please provide the docker command for installing native library and copying them at runtime via docker? Trying for almost a day, but couldn't figure it out. @HakanL
@SaiGaneshKrishnan Not sure what you mean, perhaps you can use the docker example in this repo and go from there.
Hi,
I've installed the NuGet package according to the documentation (README). But if I want to convert HTML to PDF this error shows up. Am I missing something here?
I'm running this on Windows 10 1909 x64, but in further process I want this to run inside an ASP.NET core 3.1 project on Ubuntu.
Thanks for any advice
Edit: Message: Current platform is not supported
Stacktrace: at WkHtmlToPdfDotNet.ModuleFactory.GetModule() at WkHtmlToPdfDotNet.PdfTools.Load() at WkHtmlToPdfDotNet.BasicConverter.Convert(IDocument document) at WkHtmlToPdfDotNet.SynchronizedConverter.<>c__DisplayClass5_0.b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()