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

Add Mac support for library loading #142

Merged
merged 1 commit into from
Feb 12, 2021
Merged

Conversation

jasonleenaylor
Copy link
Contributor

Addresses issue #141

Copy link
Member

@ermshiperete ermshiperete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment to CHANGELOG.md - seems worth mentioning that Mac is now supported, and add +semver:minor to the commit message.

If the method names on Mac are the same as on Linux, we should solve this differently:

  • change LIBDL_NAME: private const string LIBDL_NAME = "libdl.so";

  • modify App.config and add:

    <configuration>
      <dllmap os="!windows,osx" dll="libdl.so" target="libdl.so.2" />
      <dllmap os="osx" dll="libdl.so" target="libdl.dylib"/>
    </configuration>
    

source/icu.net/NativeMethods/NativeMethods.cs Outdated Show resolved Hide resolved
Copy link
Member

@ermshiperete ermshiperete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@chrisvire
Copy link
Member

chrisvire commented Feb 12, 2021

@jasonleenaylor I will remove myself from the reviewers. I have never done this so I don't know.

@imnasnainaec
Copy link
Contributor

I'm still encountering System.AggregateException : One or more errors occurred. (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, 1): image not found): sillsdev/TheCombine#927 (comment)

@ermshiperete
Copy link
Member

The problem is that the nuget package is missing the icu.net.dll.config file.

@martin-shields-sage
Copy link

The problem is that the nuget package is missing the icu.net.dll.config file.

I have the same issue as well, even adding the config file, for some reason the DLL map is not working on mac

@ermshiperete
Copy link
Member

The problem is that the nuget package is missing the icu.net.dll.config file.

I have the same issue as well, even adding the config file, for some reason the DLL map is not working on mac

@martin-shields-sage What mono version are you using? What icu-dotnet version? And can you show the exception you're getting including a stack trace?

@martin-shields-sage
Copy link

Exception Message:
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, 1): image not found

Stack Trace:
at Icu.NativeMethods.dlopen(String file, Int32 mode) at Icu.NativeMethods.GetIcuLibHandle(String basename, Int32 icuVersion) at Icu.NativeMethods.LoadIcuLibrary(String libraryName) at Icu.NativeMethods.get_IcuCommonLibHandle() at Icu.NativeMethods.u_init(ErrorCode& errorCode) at Icu.Wrapper.Init() at testLocal.Program.Main(String[] args) in /Users/martin.shields/Projects/testLocal/testLocal/Program.cs:line 14

Mono Version
Mono JIT compiler version 6.12.0.162 (2020-02/2ca650f1f62 Tue Nov 30 10:18:09 EST 2021)

For some reason it appears to be ignoring the config file which was added and insisting on using libdl.so instead of libdl.dylib.

Not sure if I am doing something wrong but I ran dotnet pack on the project and used that nuget package which did include the config file

@ermshiperete
Copy link
Member

Unfortunately I don't have a Mac available, so can't test this.

Make sure you have the icu.net.dll.config next to the icu.net.dll binary in the same directory as your test app.

@rmunn rmunn mentioned this pull request Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants