Bug 279057 - lang/dotnet F# gtksharp program does not build ,error libdl.so.2
Summary: lang/dotnet F# gtksharp program does not build ,error libdl.so.2
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Gleb Popov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-17 15:08 UTC by Alain De Vos
Modified: 2024-12-28 20:03 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (arrowd)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alain De Vos 2024-05-17 15:08:06 UTC
Creating an F# gtksharp "hello world" project.
dotnet run fails with

```

Unhandled exception. System.TypeInitializationException: The type initializer for 'Gtk.Application' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'libdl.so.2' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
Cannot open "/usr/local/dotnet/shared/Microsoft.NETCore.App/8.0.0/libdl.so.2"
Cannot open "/mnt/xxx_source/Languages_ok/fsharptut/65_gtk/c_treestore/bin/Debug/net8.0/libdl.so.2"
Shared object "libdl.so.2" not found, required by "fsharp_gtk"
Cannot open "/usr/local/dotnet/shared/Microsoft.NETCore.App/8.0.0/liblibdl.so.2"
Cannot open "/mnt/xxx_source/Languages_ok/fsharptut/65_gtk/c_treestore/bin/Debug/net8.0/liblibdl.so.2"
Shared object "liblibdl.so.2" not found, required by "fsharp_gtk"
Cannot open "/usr/local/dotnet/shared/Microsoft.NETCore.App/8.0.0/libdl.so.2.so"
Cannot open "/mnt/xxx_source/Languages_ok/fsharptut/65_gtk/c_treestore/bin/Debug/net8.0/libdl.so.2.so"
Shared object "libdl.so.2.so" not found, required by "fsharp_gtk"
Cannot open "/usr/local/dotnet/shared/Microsoft.NETCore.App/8.0.0/liblibdl.so.2.so"
Cannot open "/mnt/xxx_source/Languages_ok/fsharptut/65_gtk/c_treestore/bin/Debug/net8.0/liblibdl.so.2.so"
Shared object "liblibdl.so.2.so" not found, required by "fsharp_gtk"

   at FuncLoader.Linux.dlopen(String path, Int32 flags)
   at FuncLoader.LoadLibrary(String libname)
   at GLibrary.TryGet(Library library, IntPtr& ret)
   at GLibrary.Load(Library library)
   at Gtk.Application..cctor()
   --- End of inner exception stack trace ---
   at Gtk.Application.Init()
   at Program.main(String[] a) in /mnt/xxx_source/Languages_ok/fsharptut/65_gtk/c_treestore/Program.fs:line 31

```
Comment 1 Stefan Schlosser 2024-05-17 16:28:10 UTC
Be aware that GtkSharp got "support for unknown Unix" in June last year:
https://github.com/GtkSharp/GtkSharp/commit/0aebcd24d31e35117f1eaed30be76bb671946900

Without this it will try to open libdl.so.2 for Linux instead of libc for FreeBSD.

Now I'm a noob in C# and I don't know anything about F#, but can it be that the F# gtksharp "hello world" project is using an old local copy of GtkSharp without the above commit?

As a side note: building GtkSharp itself on FreeBSD didn't work for me:
https://forums.freebsd.org/threads/c-building-gtksharp-with-lang-dotnet-and-cake.92266
I don't know if this is intrinsically relevant for this bug report, just for your information.
Comment 2 Gleb Popov freebsd_committer freebsd_triage 2024-12-28 20:03:39 UTC
Does update to .NET 9 improve things regarding this bug?