0

I'm running a .net application that requires a reference to libdl.so

System.DllNotFoundException : Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibdl.so, 0x0001): tried: 'liblibdl.so' (no such file), '/usr/local/lib/liblibdl.so' (no such file), '/usr/lib/liblibdl.so' (no such file), '/Users/Amplicity/Documents/liblibdl.so' (no such file)

After some light reading, i found that libdl.so is the linux equivalent of libdl.dylib, I then tried to find libdl.dylib on my machine.

➜  lib locate libdl.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libdl.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libdl.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libdl.dylib

There are only tvos, watchos, and ios signed libdl.dylib's available. Some more light reading reveals that somewhere around xcode 7, .dylib files were replaced with .tbd, which is a text file that references dylibs elsewhere.

➜  lib locate libdl.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/lib/libdl.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/lib/libdl.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libdl.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/lib/libdl.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/lib/libdl.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libdl.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libdl.tbd
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/lib/libdl.tbd
/Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk/usr/lib/libdl.tbd
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib/libdl.tbd
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libdl.tbd

I attempted to symlink the .tbd to the .so that my .net application expects, but .net complained that it was net a mach-o file.

I then attempted to symlink the tvos .dylib to the .so, and got a different error stating that it needed to be signed for macos.

How can I find/conjure libdl.dylib on macOS12, so that I may directly reference it in my application?

jamesdlivesinatree
  • 1,016
  • 3
  • 11
  • 36
  • 1
    You don't need `libdl.dylib`. In the macOS SDK, `libdl.tbd` is a symlink to `libSystem.tbd`, which is always linked, so anything you could need from libdl is already available anyway. That said, your program seems to search for `liblibdl.so`, not `libdl.so`, so either it's looking for a different library, or it's looking, with the wrong name, for a library that is always loaded. – Siguza Jun 18 '22 at 16:00
  • Thank you! it does look for liblibdl.so, and I can see where it's looking, but that dependency cannot be found anywhere it's looking. How can I find the location of `liblibdl.so` so I can make sure the application looks in the correct spot? – jamesdlivesinatree Jun 21 '22 at 16:18
  • 1
    `liblibdl` is not a system library, so I have no idea where it comes from. – Siguza Jun 21 '22 at 20:36
  • I'm sorry, i'm a bit confused -- you said that my program (which is using tesseract, that's where this dependency requirement comes from) should search for `liblibdl.so`, which is included somewhere within the `libSystem.tbd` reference, but there's no way to directly reference the `liblibdl.so` library? Could you elaborate? having a hard time wrapping my head around what i'm dealing with – jamesdlivesinatree Jun 22 '22 at 16:57
  • 1
    No. I'm saying `libdl` and `liblibdl` sounds like two different things. Further, `libdl` is not a thing on macOS because dynamic linking functionality is part of libSystem, but the SDK aliases `libdl` to `libSystem`, likely so that ancient code that tries to link against libdl will compile fine. What `liblibdl` is supposed to be though I have no idea, but it couldn't be part of the OS simply due to the `.so` extension already. So either you're supposed to bring that library yourself, or your code is not compatible with macOS. What does your code actually use the library for? – Siguza Jun 22 '22 at 23:51
  • Thank you for explaining here. The library that references it is [tesseract](https://github.com/charlesw/tesseract/issues/588), a tesseract-ocr wrapper for .net. The linked issue is very relevant, although it seems to apply a fix to reference the `.dylib`, which I won't have. – jamesdlivesinatree Jun 30 '22 at 17:18

1 Answers1

0

I suppose you cannot rebuild that application, cause currently libdl.so` would not be requested as it is not deployed anymore as standalone.

Try to make symlink of libdl.so to libc.so (or whichever version is installed with your .net platform package, libc.so.x)

Asperi
  • 228,894
  • 20
  • 464
  • 690
  • Thanks for your response here! `libc.so` is expected to be installed with .net? or is this from mac os? How can I find the location of `libc.so.x` ? – jamesdlivesinatree Jun 27 '22 at 20:05