First time here? Checkout the FAQ!
x
0 votes
by (480 points)

Hi,

I was trying to install OpenCarp on macOS with M3 Max chip, following the building from source instructions, while I am building using CMake, I have complied this command: "cmake -S. -B_build -DDLOPEN=ON -DBUILD_EXTERNAL=ON -DCMAKE_BUILD_TYPE=Release" without an issue, but when I am tring to complie:"cmake --build _build", I got an error:

[  1%] Built target generate_ION_IF_datatypes_h

[ 10%] Built target param

[ 12%] Built target param-bin

[ 13%] Built target carp

[ 18%] Built target numerics

[ 19%] Built target fem

[ 69%] Built target limpet

[ 71%] Built target physics

[ 73%] Built target simulator

[ 73%] Building CXX object CMakeFiles/opencarp-bin.dir/simulator/main.cc.o

gmake[2]: /usr/local/Cellar/llvm/5.0.1/bin/clang++: No such file or directory

gmake[2]: *** [CMakeFiles/opencarp-bin.dir/build.make:79: CMakeFiles/opencarp-bin.dir/simulator/main.cc.o] Error 127

gmake[1]: *** [CMakeFiles/Makefile2:398: CMakeFiles/opencarp-bin.dir/all] Error 2

gmake: *** [Makefile:156: all] Error 2

I have installed Clang++, which is located at "/opt/homebrew/opt/llvm/bin/clang++". I tried to add this to the PATH, and also tried to replace the location in "CMakeFiles/opencarp-bin.dir/build.make" file, but neither one worked. Could someone help me with this issue?

Thank you so much

1 Answer

0 votes
by (960 points)

Hey, 

it seems like your cmake tries to access clang with an old (non-existing) path. To my understanding, (on newer Macs at least) homebrew does not install packages in  /usr/local/Cellar/ anymore but rather in /opt/homebrew/Cellar.

Try the following to let cmake make use of the llvm installed by homebrew:

# Set standard C compilers

export CC=clang

export CXX=clang++

# Set LLVM ENVs

export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"

export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

# Update PATH env

PATH=/opt/homebrew/bin:$PATH

PATH=/opt/homebrew/opt/llvm/bin:$PATH

export PATH

Hope this helps! 

by (960 points)

Don't forget to clear the cmake cache by deleting CMakeCache.txt CMakeFiles in your build directory and reconfigure using 

cmake -S. -B_build -DDLOPEN=ON -DBUILD_EXTERNAL=ON -DCMAKE_BUILD_TYPE=Release

PS: if you are using the preinstalled python version of MacOS and it is still python 3.9, you might run into problems with building the external tools. If that seems to be the case, build with -DBUILD_EXTERNAL=OFF first and see if openCARP compiles correctly. With more recent python versions it should not create problems.

by (480 points)

Thank you so much for your response. I did this and it worked for a while, but I got another error:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:175:5: note: 

      expanded from macro 'isinf'

  175 |     ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \

      |     ^

In file included from /Users/user/openCARP/numerics/basics.cc:27:

In file included from /Users/user/openCARP/numerics/basics.h:40:

In file included from /opt/homebrew/opt/petsc/include/petscsys.h:44:

In file included from /opt/homebrew/opt/petsc/include/petscsystypes.h:570:

/opt/homebrew/Cellar/llvm/21.1.1/bin/../include/c++/v1/complex:1033:12: error: 

      expected unqualified-id

 1033 |   if (std::isinf(__theta)) {

      |            ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:175:5: note: 

      expanded from macro 'isinf'

  175 |     ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \

      |     ^

fatal error: too many errors emitted, stopping now [-ferror-limit=]

20 errors generated.

gmake[2]: *** [numerics/CMakeFiles/numerics.dir/build.make:79: numerics/CMakeFiles/numerics.dir/basics.cc.o] Error 1

gmake[1]: *** [CMakeFiles/Makefile2:565: numerics/CMakeFiles/numerics.dir/all] Error 2

gmake: *** [Makefile:156: all] Error 2

Then while I was trying to fix this error, I deleted the CMakeCache.txt and the CMakeFiles folder, and then somehow I got the previous error again:

gmake[2]: /usr/local/Cellar/llvm/5.0.1/bin/clang++: No such file or directory

I checked the PATH and other environment again and they have all been set up correctly. Please let me know if you have any ideas on how to fix this. Thank you again.

by (960 points)

I guess your first step should be to get rid of this old installation of homebrew to avoid other future interferences. This version was probably transferred over from an old Intel based Mac via a backup or similar when you set up the current Mac, since on all Apple Silicon Macs the installation prefix of homebrew should be /opt/homebrew.

To uninstall the old homebrew install, remove /usr/local/Cellar and all symlinks into it from /usr/local/bin.

If you have any old environment variables etc. setup remove them as well.

Did you setup your bash.rc or similar with the variables I posted before? If not, they will be gone as soon as you open a new terminal instance.

Regarding your new error, did you change something in the code of openCARP that created this error?

ago by (480 points)

I had an Intel Mac before, but I had never installed Homebrew until recently, and I checked on my current computer that I don't have a folder /usr/local/Cellar, and I don't think I found any symlinks in /usr/local/bin with Cellar or a similar name.

I didn't setup a bash.rc, but I did setup all the variables you have posted in your previous comment. What should I do with bash.rc? Put the variables in it?

And I don't believe I have made any changes to the code of openCARP, but since the error is expected unqualified-id, I have checked the file for any misalignment or missing bracket but I didn't find any.

ago by (960 points)

If /usr/local/bin does not exist on your machine, but cmake still tries to use the llvm compiler from it, there has to be some env variable etc. that still points to this location. Otherwise, cmake would use the built in compiler from Mac. But lets start over:

Since you are on Mac, the standard shell is zsh. You can confirm this by running echo $0 in your terminal. That means the relevant file for you is not .bashrc (sorry, typed it out wrong in my previous answer) but .zshrc in your home directory. This is a configuration file for your zsh shell and will set things like environment variables automatically every time you open a new shell.

If you just type the commands I gave you in the terminal, it will also work. But as soon as you close the terminal window (or open a new one), those variables will disappear. Therefore, what you want to do is put the commands I gave you before into this .zshrc file:

# Set standard C compilers

export CC=clang

export CXX=clang++

# Set LLVM ENVs

export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"

export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

# Update PATH env

PATH=/opt/homebrew/bin:$PATH

PATH=/opt/homebrew/opt/llvm/bin:$PATH

export PATH

Maybe this file also contains the env variable that points to /usr/local/Cellar. If you find that, it should be safe to delete the line from the file or simply comment it. 

If you have done that, open a new terminal window, go to your openCARP directory and do

rm -r _build (to remove old build files)

cmake -S. -B_build -DDLOPEN=ON -DBUILD_EXTERNAL=ON -DCMAKE_BUILD_TYPE=Release

cmake --build _build

If you have done all the steps correctly, it should compile. If the other error comes up again, we can take a closer look at that. If you have not changed the source code in any way, I find it unusual that this error comes up, since I have not seen it yet with openCARP and we have a lot of Mac users at our institute.

Welcome to openCARP Q&A. Ask questions and receive answers from other members of the community. For best support, please use appropriate TAGS!
architecture, carputils, documentation, experiments, installation-containers-packages, limpet, slimfem, website, governance
...