Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Error installing Cairo on M1 chip (gmp.h) #22

Closed
howardpen9 opened this issue Oct 16, 2021 · 19 comments
Closed

Error installing Cairo on M1 chip (gmp.h) #22

howardpen9 opened this issue Oct 16, 2021 · 19 comments

Comments

@howardpen9
Copy link

image

As you can see, when I try to compile the cairo file, it show with these error. I tried to search on Google but can't find with any ideas. I think it's out of my knowledge, anyone know how to solve this? Thank you.

@martriay
Copy link
Contributor

martriay commented Oct 17, 2021

This seems to be an issue with the Cairo programming language on apple's M1 computers. I read on the Cairo discord that you were able to solve it. Leaving a few success stories taken from the Cairo discord server for anybody stumbling upon this very problem:

1. @guiltygyoza

Replying to myself for a working solution for M1-chip machine, the key to which is to install the x86 homebrew and use that to install & link gmp

  1. Duplicate the terminal app and name it something else e.g. terminal_rosetta; set it to Open using Rosetta . Reference: https://medium.com/swlh/run-x86-terminal-apps-like-homebrew-on-your-new-m1-mac-73bdc9b0f343
  2. In terminal_rosetta, open a virtual environment running python 3.7
  3. Install the x86 homebrew by running arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" . It will get installed in /usr/local/
  4. Use the x86 brew to install gmp by running /usr/local/bin/brew install gmp
  5. Use the x86 brew to link gmp by running /usr/local/bin/brew link gmp
  6. Follow the rest of the quickstart tutorial at https://www.cairo-lang.org/docs/quickstart.html

2. @milancermak

in case anyone else runs into this error fatal error: 'gmp.h' file not found when installing the necessary Cairo packages on a M1 Mac, after brew install gmp, try this:
CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip install ecdsa fastecdsa sympy

3. @howardpen9

The python library fastecdsa has the issued in new MacOS or M1 chips I think!! You can't install the latest version. I reinstall the each version until the fastecdsa==1.7.5 to run the code successfully! Finally!

4. myself!

None of the above worked for me :(
So I ended up spinning up a docker instance with ubuntu and installed Cairo in it.

@martriay martriay changed the title When type 'nile compile', got the error. Error installing Cairo on M1 chip (gmp.h) Oct 17, 2021
@milancermak
Copy link
Contributor

To make mine more generic, try:

CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip install ecdsa fastecdsa sympy

@martriay
Copy link
Contributor

Edited!

@0xs34n
Copy link

0xs34n commented Jan 21, 2022

I would suggest pinning this issue @martriay

@martriay martriay pinned this issue Jan 21, 2022
@martriay
Copy link
Contributor

Done

@machard
Copy link

machard commented Jan 31, 2022

@milancermak trick fixed it for me.
probably worth editing https://www.cairo-lang.org/docs/quickstart.html#quickstart

@clacladev
Copy link

clacladev commented Feb 16, 2022

I tried the @milancermak solution, but on my macOS Monterey (12.1) on M1, pip is not found, while pip3 is.
So modifying Milan's command to the following, I was then able to pip3 install cairo-lang successfully.

CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip3 install ecdsa fastecdsa sympy

@QEDK
Copy link

QEDK commented Feb 26, 2022

To make mine more generic, try:

CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip install ecdsa fastecdsa sympy

Worked for me! Appreciate it.

@benminer
Copy link

Option 1 worked for me, thank you!

@daramir
Copy link

daramir commented Apr 19, 2022

Got it to work using:

@chee-chyuan
Copy link

chee-chyuan commented Apr 20, 2022

fastecdsa==1.7.5

this works for me. thank you so much. but compiling doesnt work :(

@chee-chyuan
Copy link

some kind soul posted this and it works for me https://th0rgal.medium.com/the-easiest-way-to-setup-a-cairo-dev-environment-8f2a63610d46

@zinderud
Copy link

CFLAGS=-Ibrew --prefix gmp/include LDFLAGS=-Lbrew --prefix gmp/lib pip3 install ecdsa fastecdsa sympy

Thanks, I've been trying to figure this out for days. This time it happened

@clement-ux
Copy link

To make mine more generic, try:

CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip install ecdsa fastecdsa sympy

I'm using M1 chip, this works for me, thanks!

@bleso-a
Copy link

bleso-a commented Jul 5, 2022

I am also using M1 Chip, the command below also works for me

CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip install ecdsa fastecdsa sympy

@emmaguo13
Copy link

emmaguo13 commented Jul 18, 2022

Compiling works for me, but not execution. I'm getting the same error as this one here: AntonKueltz/fastecdsa#74 (comment)
Probably will just spin up a docker container, but would love to know if execution works for any of you!

@Coun1er
Copy link

Coun1er commented Oct 3, 2022

I am also using M1 Chip, the command below also works for me

CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip install ecdsa fastecdsa sympy

And me on Mac m1 pro chip

@ccsols
Copy link

ccsols commented Mar 27, 2023

I tried the @milancermak solution, but on my macOS Monterey (12.1) on M1, pip is not found, while pip3 is. So modifying Milan's command to the following, I was then able to pip3 install cairo-lang successfully.

CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip3 install ecdsa fastecdsa sympy

Thx! This worked for me! I ran this command after completely removing python on machine (reinstalling python3.9).

@Samk13
Copy link

Samk13 commented May 11, 2023

To fix this error:

OSError: no library called "cairo-2" was found
no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 0x0002): tried: 'libcairo.so.2' (no such file), '/usr/local/lib/libcairo.so.2' (no such file), '/usr/lib/libcairo.so.2' (no such file), '/Users/soma/Development/mkdocs-material-insiders/libcairo.so.2' (no such file), '/usr/local/lib/libcairo.so.2' (no such file), '/usr/lib/libcairo.so.2' (no such file)
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 0x0002): tried: 'libcairo.2.dylib' (no such file), '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file), '/Users/soma/Development/mkdocs-material-insiders/libcairo.2.dylib' (no such file), '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file)
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 0x0002): tried: 'libcairo-2.dll' (no such file), '/usr/local/lib/libcairo-2.dll' (no such file), '/usr/lib/libcairo-2.dll' (no such file), '/Users/soma/Development/mkdocs-material-insiders/libcairo-2.dll' (no such file), '/usr/local/lib/libcairo-2.dll' (no such file), '/usr/lib/libcairo-2.dll' (no such file)

run this command:
ln -s /opt/homebrew/lib/libcairo.2.dylib .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests