-
Notifications
You must be signed in to change notification settings - Fork 210
Closed
Description
When I add {:exla, "~> 0.9.0"}
as a dependency and run mix compile
I get the following error:
** (Mix) Could not compile with "make" (exit status: 2).
You need to have gcc and make installed. Try running the
commands "gcc --version" and / or "make --version". If these programs
are not installed, you will be prompted to install them.
gcc
and make
are available at /usr/bin
, which is on my PATH.
I first encountered the error in LiveBook with Mix.install
, but putting it in a regular mix.exs
file gives the same error.
I'm on a 2023 MacBook Pro with Apple M2 Pro chip and running macOS Sonoma 14.6.1

Activity
josevalim commentedon Oct 1, 2024
Can you paste everything that was printed since
mix compile
ormix deps.compile
. There may be more important information before the messages in red.CoderDennis commentedon Oct 1, 2024
josevalim commentedon Oct 1, 2024
So this is the root cause:
Have you installed XCode command line tools?
xcode-select --install
?CoderDennis commentedon Oct 1, 2024
I checked System Settings and XCode was not listed in available updates.
I'm running the Sonoma update to see if that makes a difference.
josevalim commentedon Oct 1, 2024
This is weird. It says your computer is missing some fundamental C++ libraries (memory.h is C++ 98 iirc). So something in your machine is missing or your env vars is pointing to a separate C++ installation. For example, I can find
memory
atcat /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory
CoderDennis commentedon Oct 1, 2024
I found it in
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/
and added that to my PATH, but it didn't seem to make a difference.josevalim commentedon Oct 1, 2024
I don't think PATH is used for library/header files. It uses other keys but I am not sure. This article may have some hints: https://www.maven.de/2020/05/using-clang-on-macos-to-compile-g-libstdc-compatible-binaries/
seanmor5 commentedon Oct 1, 2024
I think for includes you need
CPLUS_INCLUDE_PATH
CoderDennis commentedon Oct 1, 2024
On StackOverflow I found the command
gcc -v -E - < /dev/null
which lists directories that are searched for includes. It shows/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
in the list which does havememory.h
in it on my machine.CPLUS_INCLUDE_PATH
was empty (or not set ?) so I set it to that same include directory, but that didn't make a difference.CoderDennis commentedon Oct 1, 2024
Now I have also tried editing the
deps/exla/Makefile
by adding more-I
parameters toCFLAGS
for the directories that containmemory.h
andsstream.h
but the errors that those files aren't found persist. 🤷I also re-installed the XCode Command Line Tools.
CoderDennis commentedon Oct 2, 2024
I tried again today with editing
Makefile
. Adding-I/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/c++/v1
to theCFLAGS
on line 28 removes all the errors.That works for using
mix compile
on a regular project from the command line. The following works in LiveBook:CoderDennis commentedon Oct 2, 2024
So, to sum up, the directory @josevalim mentioned
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
added to the environment variable @seanmor5 mentionedCPLUS_INCLUDE_PATH
made it work. Thank you both!josevalim commentedon Oct 2, 2024
For Livebook, if you go to the menu, it can open up .livebookdesktop.sh and you can configure any env var you want there.