Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[.NET Core 3.1] System.DllNotFoundException: Unable to load shared library 'libcups' or one of its dependencies. #52696

Closed
apetrut opened this issue May 13, 2021 · 7 comments
Labels
area-System.Drawing untriaged New issue has not been triaged by the area owner

Comments

@apetrut
Copy link

apetrut commented May 13, 2021

Hi,

When trying to print from a .NET Core 3.1 app, I ran into the error below:

System.DllNotFoundException: Unable to load shared library 'libcups' or one of its dependencies.
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibcups: cannot open shared object file: No such file or directory
  at System.Drawing.Printing.LibcupsNative.cupsTempFd(StringBuilder sb, Int32 len)
  at System.Drawing.Printing.PrintingServices.CreateGraphicsContext(PrinterSettings settings, PageSettings default_page_settings)
  at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
  at System.Drawing.Printing.PrintDocument.Print()

I am running the code inside a Linux container and the docker file looks like below:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic AS base
RUN apt-get update && apt-get install -y gnupg2
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_1
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_2

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository 'deb http://deb.debian.org/debian sid main'
RUN apt-get update
    
RUN apt-get install -y libc6-dev 
RUN apt-get install -y libgdiplus
RUN apt-get install -y libicu-dev libharfbuzz0b libfontconfig1 libfreetype6
RUN apt-get install -y libpango-1.0-0
RUN apt-get install -y libpangocairo-1.0
RUN apt-get update

ENV LD_DEBUG=libs

The output also displays several other errors which may be related:

/usr/lib/x86_64-linux-gnu/libicuuc.so.67: error: symbol lookup error: undefined symbol: u_strlen (fatal)

293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetDefaultLocaleNameW (fatal)
293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetTimeZoneDisplayNameW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_CompareStringW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleNameW (fatal)
 293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleInfoStringW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_StartsWithW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_EndsWithW (fatal)
 293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetCalendarsW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleTimeFormatW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetCalendarInfoW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_EnumCalendarInfoW (fatal)

/usr/lib/x86_64-linux-gnu/libssl.so.1.1: error: symbol lookup error: undefined symbol: SSL_state (fatal)

@mellinoe , in this refactoring the libcups dll is manually loaded. However I can't see if it has any dependency that might cause the above errors to appear.

Do you know what dependencies the libcups dll have and are missing?

Also I installed libicu-dev but it still complains that u_strlen symbol was not loaded which is very weird.

Thanks,
Andrei

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Globalization untriaged New issue has not been triaged by the area owner labels May 13, 2021
@ghost
Copy link

ghost commented May 13, 2021

Tagging subscribers to this area: @tarekgh, @safern
See info in area-owners.md if you want to be subscribed.

Issue Details

Hi,

When trying to print a simple .pdf file I ran into the error below:

System.DllNotFoundException: Unable to load shared library 'libcups' or one of its dependencies.
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibcups: cannot open shared object file: No such file or directory
  at System.Drawing.Printing.LibcupsNative.cupsTempFd(StringBuilder sb, Int32 len)
  at System.Drawing.Printing.PrintingServices.CreateGraphicsContext(PrinterSettings settings, PageSettings default_page_settings)
  at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
  at System.Drawing.Printing.PrintDocument.Print()

I am running the code inside a Linux container and the docker file looks like below:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic AS base
RUN apt-get update && apt-get install -y gnupg2
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_1
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_2

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository 'deb http://deb.debian.org/debian sid main'
RUN apt-get update
    
RUN apt-get install -y libc6-dev 
RUN apt-get install -y libgdiplus
RUN apt-get install -y libicu-dev libharfbuzz0b libfontconfig1 libfreetype6
RUN apt-get install -y libpango-1.0-0
RUN apt-get install -y libpangocairo-1.0
RUN apt-get update

ENV LD_DEBUG=libs

The output also displays several other errors which may be related:

/usr/lib/x86_64-linux-gnu/libicuuc.so.67: error: symbol lookup error: undefined symbol: u_strlen (fatal)

293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetDefaultLocaleNameW (fatal)
293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetTimeZoneDisplayNameW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_CompareStringW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleNameW (fatal)
 293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleInfoStringW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_StartsWithW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_EndsWithW (fatal)
 293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetCalendarsW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleTimeFormatW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetCalendarInfoW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_EnumCalendarInfoW (fatal)

/usr/lib/x86_64-linux-gnu/libssl.so.1.1: error: symbol lookup error: undefined symbol: SSL_state (fatal)

@mellinoe , in this refactoring the libcups dll is manually loaded. However I can't see if it has any dependency that might cause the above errors to appear.

Do you know what dependencies the libcups dll have and are missing?

Also I installed libicu-dev but it still complains that u_strlen symbol was not loaded which is very weird.

Thanks,
Andrei

Author: apetrut
Assignees: -
Labels:

area-System.Globalization, untriaged

Milestone: -

@apetrut apetrut changed the title System.DllNotFoundException: Unable to load shared library 'libcups' or one of its dependencies. (.NET Core) System.DllNotFoundException: Unable to load shared library 'libcups' or one of its dependencies. May 13, 2021
@apetrut apetrut changed the title (.NET Core) System.DllNotFoundException: Unable to load shared library 'libcups' or one of its dependencies. [.NET Core 3.1] System.DllNotFoundException: Unable to load shared library 'libcups' or one of its dependencies. May 13, 2021
@ghost
Copy link

ghost commented May 13, 2021

Tagging subscribers to this area: @safern, @tarekgh
See info in area-owners.md if you want to be subscribed.

Issue Details

Hi,

When trying to print from a .NET Core 3.1 I ran into the error below:

System.DllNotFoundException: Unable to load shared library 'libcups' or one of its dependencies.
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibcups: cannot open shared object file: No such file or directory
  at System.Drawing.Printing.LibcupsNative.cupsTempFd(StringBuilder sb, Int32 len)
  at System.Drawing.Printing.PrintingServices.CreateGraphicsContext(PrinterSettings settings, PageSettings default_page_settings)
  at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
  at System.Drawing.Printing.PrintDocument.Print()

I am running the code inside a Linux container and the docker file looks like below:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic AS base
RUN apt-get update && apt-get install -y gnupg2
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_1
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_2

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository 'deb http://deb.debian.org/debian sid main'
RUN apt-get update
    
RUN apt-get install -y libc6-dev 
RUN apt-get install -y libgdiplus
RUN apt-get install -y libicu-dev libharfbuzz0b libfontconfig1 libfreetype6
RUN apt-get install -y libpango-1.0-0
RUN apt-get install -y libpangocairo-1.0
RUN apt-get update

ENV LD_DEBUG=libs

The output also displays several other errors which may be related:

/usr/lib/x86_64-linux-gnu/libicuuc.so.67: error: symbol lookup error: undefined symbol: u_strlen (fatal)

293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetDefaultLocaleNameW (fatal)
293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetTimeZoneDisplayNameW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_CompareStringW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleNameW (fatal)
 293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleInfoStringW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_StartsWithW (fatal)
293:	/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_EndsWithW (fatal)
 293: /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetCalendarsW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetLocaleTimeFormatW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_GetCalendarInfoW (fatal)
 293:/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.15/System.Globalization.Native.so: error: symbol lookup error: undefined symbol: GlobalizationNative_EnumCalendarInfoW (fatal)

/usr/lib/x86_64-linux-gnu/libssl.so.1.1: error: symbol lookup error: undefined symbol: SSL_state (fatal)

@mellinoe , in this refactoring the libcups dll is manually loaded. However I can't see if it has any dependency that might cause the above errors to appear.

Do you know what dependencies the libcups dll have and are missing?

Also I installed libicu-dev but it still complains that u_strlen symbol was not loaded which is very weird.

Thanks,
Andrei

Author: apetrut
Assignees: -
Labels:

area-System.Drawing, area-System.Globalization, untriaged

Milestone: -

@jkotas
Copy link
Member

jkotas commented May 13, 2021

@mthalman It would be nice to have a recipe for how people can solve problems like this one using your dependencies inventory.

@mthalman
Copy link
Member

Related to dotnet/core#5651

@apetrut - The .NET Docker images do not contain all possible dependencies that .NET has. It only contains dependencies for mainline scenarios. In this case, printing does require the cups package. You should be able to resolve this by including cups in the list of packages that you install. This provides the libcups.so.2 file.

@apetrut
Copy link
Author

apetrut commented May 13, 2021

@mthalman , I tried to install libcups using the line below:

RUN apt-get install -y libcups

but instead I got this error:

Unable to locate package libcups
The command '/bin/sh -c apt-get install -y libcups' returned a non-zero code: 100

@mthalman
Copy link
Member

It's cups, not libcups.

@apetrut
Copy link
Author

apetrut commented May 13, 2021

Thanks, it works now. I no longer receive the errors above.

The final docker file looks like this:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic AS base

ENV TZ=Europe/Bucharest
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get install -y gnupg2
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys Your_Missing_Key_1
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys Your_Missing_Key_2

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository 'deb http://deb.debian.org/debian sid main'
RUN apt-get update

RUN apt-get install -y cups
RUN apt-get install -y libc6-dev 
RUN apt-get install -y libgdiplus
RUN apt-get install -y libicu-dev libharfbuzz0b libfontconfig1 libfreetype6
RUN apt-get install -y libpango-1.0-0
RUN apt-get install -y libpangocairo-1.0
RUN apt-get update

Regards,
Andrei

@apetrut apetrut closed this as completed May 13, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Drawing untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

3 participants