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

Even if libsdoium is installed, the storage location of libsodium cannot be obtained #116

Open
TakumiHoriguchi opened this issue Oct 21, 2024 · 13 comments

Comments

@TakumiHoriguchi
Copy link

Hello,
I am developing using Mac and Debian.(macOS sonoma 14.5)
I installed libsodium, but the search for the line below doesn't work well, and the error message on line 35 is returned.
libsodium is installed using the following method
on mac
brew install libsodium
In debian
apt-get apt-get install -y libsodium-dev

On Mac, it works if you hardcode the path on line 33. You can't do that with debian.

sodium = ctypes.cdll.LoadLibrary(ctypes.util.find_library('sodium') or ctypes.util.find_library('libsodium'))

If you have any problems with my usage, please teach me the steps. thank you.

Thanks for the amazing work so far !
(This is an automatic translation)

@stef
Copy link
Owner

stef commented Nov 10, 2024

sorry for the late answer, another project took all my attention. what do you mean with hard-coding the path in line 33? what would be that path? i have no access to macs, help me out by debugging this for me and figuring out a reliable way to support macs as well. thank you very much!

@stef
Copy link
Owner

stef commented Nov 10, 2024

googled a bit, it seems that brew doesn't install libraries in any of /usr/lib lor /usr/local/lib but somewhat random locations instead. i don't really know how to guess these correctly, i think it is better to just make a symlink to libsodium into either /usr/lib or /usr/local/lib, it will be picked up there correctly. why brew does this, i dunno, maybe open a ticket with brew to fix this?

@jedisct1
Copy link
Contributor

pkg-config --libs libsodium and pkg-config --cflags libsodium work no matter where the library is installed as long as the tool itself is in the PATH. Which is the case with Brew.

@stef
Copy link
Owner

stef commented Nov 10, 2024

oh, so you say i get the path using os.system('pkg-config --libs') instead of find_library, hmm, that could work, not nice, but it sounds workable..

@jedisct1
Copy link
Contributor

jedisct1 commented Nov 10, 2024

I'm not very familiar at all with cmake, but looks like it has FindPkgConfig to do that: https://stackoverflow.com/questions/29191855/what-is-the-proper-way-to-use-pkg-config-from-cmake

Scratch that, this is not using cmake :)

@stef
Copy link
Owner

stef commented Nov 10, 2024

not sure we are talking about the same thing. this is about python ctypes.find_library not finding libsodium, has nothing to do with cmake.

@TakumiHoriguchi
Copy link
Author

sorry for the late answer, another project took all my attention. what do you mean with hard-coding the path in line 33? what would be that path? i have no access to macs, help me out by debugging this for me and figuring out a reliable way to support macs as well. thank you very much!

Thank you for your reply.
Sorry for the late reply. It's because of the time difference.

The hardcoded path is below.
/opt/homebrew/Cellar/libsodium/1.0.20/lib/libsodium.dylib

I also tried moving libsodium, which was installed with brew, to usr/lib, but the result was the same.

@stef
Copy link
Owner

stef commented Nov 11, 2024

hmm, pkg-config -l doesn't work it only gives me the linker flags, like -lsodium not a path.

@stef
Copy link
Owner

stef commented Nov 11, 2024

it's not very convenient to have also the version in the path /opt/homebrew/Cellar/libsodium/1.0.20/lib/libsodium.dylib this makes it extra painful to find the library.

@stef
Copy link
Owner

stef commented Nov 11, 2024

according to the wisdom of mastodon, you should:

contact the maintainer of the brew libsodium install script. They need to add a link to /opt/homebrew/lib/ for Apple Silicon. Intel brew probably puts it in /usr/local/lib.

the install script should put a link to the lib into /usr/local/lib then it will be picked up perfectly by ctypes and pysodium.

@stef
Copy link
Owner

stef commented Nov 11, 2024

btw is there no link in /opt/homebrew/lib to libsodium?

@stef
Copy link
Owner

stef commented Nov 11, 2024

the dear people at cynthion had a similar issue, and the solution is to use brew python which nows how to find other brew stuff: greatscottgadgets/cynthion#136

@stef
Copy link
Owner

stef commented Nov 11, 2024

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

No branches or pull requests

3 participants