How to install libffi-dev on Mac OS X
Asked Answered
D

3

17

I am trying to implement micropython on unix, which requires libffi-dev. I installed in this way brew install libffi-dev. But it seems that there is no libffi-dev can be found.

Is there any way to install libffi-dev on Mac os. Thank you.

Discomfiture answered 22/6, 2017 at 17:52 Comment(5)
Try brew install libffi.Agreeable
If this worked you should answer the question and accept it.Molarity
@PaulR Thank you Paul. brew install libffi works on Mac. But I am confused that are libffi and libffi-dev the same thing?Discomfiture
@XiufenXu: on Linux they often separate packages into xxx and xxx-dev, where xxx contains the minimum you need just to use a library or whatever, while the xxx-dev package contains source code and other supporting files to enable you to modify and rebuild the package if needed. With Homebrew on Mac OS X you typically get all this in just one xxx package, so you won't normally see separate xxx-dev packages (although there are a few exceptions to this rule of thumb, e.g. google-chrome and google-chrome-dev).Agreeable
@PaulR That's really what I want to clear up. Thanks a lot.Discomfiture
A
37

On Mac OS X you just need:

$ brew install libffi
Agreeable answered 22/6, 2017 at 19:4 Comment(3)
Any alternative to brew, it tends to own my python whenever I use it which equals instant regret.Parham
@PaulKenjora: try MacPorts or even fink ?Agreeable
You can look at the source to figure out what it does. Go to formulae.brew.sh/formula/libffi and click "Formula code: libffi.rb on GitHub". We can see the dependencies via the depends_on: 1. autoconf 2. automake 3. libtool We can then convert it to the following: 1. git clone github.com/libffi/libffi.git 2. cd libffi 3 ./autogen.sh 4. ./configure 5. make install Homebrew shouldn't conflict with your Python, if it does you've probably installed Python via brew. You should probably be using venvs or something, it'll make your life much easier :-).Zrike
P
4

Error:

Library not loaded: /usr/local/opt/libffi/lib/libffi.7.dylib

The following worked (it’s not an ln -s but it did the trick):

sudo mkdir /usr/local/opt/libffi
sudo mkdir /usr/local/opt/libffi/lib
sudo cp /usr/lib/libffi.dylib /usr/local/opt/libffi/lib/libffi.7.dylib

Turns out Xcode already installs a library, it’s just not in the right spot.

Parham answered 15/9, 2020 at 19:18 Comment(1)
Symbolic links would probably be a better approach than copying. That way you get the correct version when you update the OS.Agreeable
B
0

This worked for me when paramiko python library was giving file not found error ::

ln -s /usr/local/opt/libffi/lib/libffi.dylib /usr/local/lib/libffi.7.dylib
Blaine answered 25/10, 2022 at 11:0 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.