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

Fix libsvm name for Darwin #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

carlocab
Copy link

@carlocab carlocab commented Sep 4, 2024

On macOS, shared libraries are expected to be installed with the naming
convention

lib$NAME.$SOVERSION.dylib

We also prefix the library install name with @rpath to indicate to the
dynamic linker that it should use RPATH to look for libsvm. Without
this, the dynamic linker will only search the calling process' current
working directory, which will, in general, not contain libsvm.

On macOS, shared libraries are expected to be installed with the naming
convention

    lib$NAME.$SOVERSION.dylib

We also prefix the library install name with `@rpath` to indicate to the
dynamic linker that it should use RPATH to look for `libsvm`. Without
this, the dynamic linker will only search the calling process' current
working directory, which will, in general, not contain `libsvm`.
@chcwww
Copy link
Contributor

chcwww commented Sep 9, 2024

We are not sure whether the change affects compatibility with previous versions on macOS.
Also, we are wondering if there is a bug or error in the current version when compiling on macOS that requires fixing.
Could you provide more details about it? Thanks.

@carlocab
Copy link
Author

carlocab commented Sep 9, 2024

We are not sure whether the change affects compatibility with previous versions on macOS.

This does affect compatibility, so it can/should probably wait until you bump SHVER, since clients of libsvm will need to be re-linked in that case anyway (and will be able to use the new libsvm.5.dylib with no further changes).

Also, we are wondering if there is a bug or error in the current version when compiling on macOS that requires fixing. Could you provide more details about it? Thanks.

Regarding naming, it's not so much an error, but I think it is a bug to not be following platform naming conventions for shared libraries. .dylib is the default extension for shared libraries found on macOS. It's also the default extension generated by build tools like CMake or Meson.

Merging this patch also means that downstream packagers don't have to fix up the file name and install name for you. See:

Homebrew, MacPorts, and Nix are probably the three most widely used package managers on macOS at the moment, and they all rename libsvm.so.* to libsvm.*.dylib.

It seems to me that there would be less duplication of effort (and therefore more efficient) if this was corrected here upstream instead.

@carlocab
Copy link
Author

carlocab commented Sep 9, 2024

Regarding the install name, what kind of details were you looking for?

In its current state you can only link with libsvm if it's in your current working directory. If you cd to somewhere else the dynamic linker will error out saying it cannot find libsvm.

With the @rpath prefix, you can pass the appropriate -rpath flag to ld so that it knows where to find libsvm.

@chcwww
Copy link
Contributor

chcwww commented Sep 16, 2024

Thanks for the information.
However, could you please provide details about the situations in which the dynamic linker cannot find libsvm with .so, and how this issue can be fixed using.dylib? (For example, where libsvm and the thing you want to link are installed, and how you link them.) Thank you.

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.

2 participants