Compiling in MacBook with M1 processor

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
rcarreno
Posts: 2
Joined: Mon Aug 29, 2011 1:54 am
Location: University of California - San Diego

Compiling in MacBook with M1 processor

Post by rcarreno »

Hello everyone
I have a MacBook Pro with an M1 Pro processor and was wondering if it is possible to compile OpeSees natively for the arm processor. I followed the compiling steps for macOS described in the GitHub documentation (https://opensees.github.io/OpenSeesDocu ... build.html) but without success. My only experience compiling OpenSees so far has been using Visual Studio in Windows 10 and 11.

I can follow all the compiling steps in the documentation without issue up to the following terminal command:
>> conan install .. --build missing

at which point I get the following error:

ERROR: The recipe conanfile.py (OpenSeesDependencies/1.0.0) is constraining settings. Invalid setting 'armv8' is not a valid 'settings.arch' value.
Possible values are ['x86_64']
Read "http://docs.conan.io/en/latest/faq/trou ... id-setting"


I was able to "fix" the issue by adding the "armv8" to the settings option in conanfile.py, but keep getting compilation errors in the following steps, and I'm unable to generate the final executable OpenSees file (I managed to get an "OpenSees.a" file at the end of the process, but didn't know what to do with it).

My computer is a MacBook Pro 14" with M1 Pro processor running MacOS Ventura (v13.1).

Thank you
Rodrigo Carreno, PhD, PE
rcarreno@gmail.com
penaf
Posts: 1
Joined: Sat Jan 07, 2023 10:00 am

Re: Compiling in MacBook with M1 processor

Post by penaf »

I have a Mac Studio Max with M1 processor and Ventura 13.1 OS.
I have been able to compile and run OpenSees in native mode under a terminal, just following the instructions:

First of all install packages with brew:
brew install gcc cmake lapack arpack numpy open-mpi hdf5 scalapack tcl-tk python-tk

Download and compile mumps:
git clone https://github.com/OpenSees/mumps.git
cd mumps
mkdir build
cd build
cmake .. -Darith=d
cmake --build . --config Release --parallel 4
cd ..

Then download and compile OpenSees:
git clone https://github.com/OpenSees/OpenSees.git
cd OpenSees
mkdir build
cd build
cmake .. -DMUMPS_DIR=$PWD/../../mumps/build -DOPENMPI=TRUE -DSCALAPACK_LIBRARIES=/opt/homebrew/lib/libscalapack.dylib
cmake --build . --config Release --target OpenSees --parallel 4
cmake --build . --config Release --target OpenSeesPy
mv ./lib/OpenSeesPy.dylib ./lib/opensees.so

To run the program I have linked the resulting OpenSees executable on /opt/homebrew/bin and the python module opensees.so on
/opt/homebrew/lib/python3.11/site-packages

To plot the results under Python I had to install:
python3.11 -m pip install matplotlib

So everything is working well even with parallel processing.
rcarreno
Posts: 2
Joined: Mon Aug 29, 2011 1:54 am
Location: University of California - San Diego

Re: Compiling in MacBook with M1 processor

Post by rcarreno »

Thank you so much for your help.
I was able to generate a dylib file and test it.
I'm now having trouble starting with the command: mv ./lib/OpenSeesPy.dylib ./lib/opensees.so
as the "lib" directory does not exist (I do get a dylib file with that name directly in the "build" folder, so I was just testing renaming that file into opensees.so)

After that, I don't quite understand what you mean by: To run the program I have linked the resulting OpenSees executable on /opt/homebrew/bin and the python module opensees.so on /opt/homebrew/lib/python3.11/site-packages. Do I need to move any file from the opensees build folder to /opt/homebrew/bin? how do I link the executable?

Thank again :)
Rodrigo Carreno, PhD, PE
rcarreno@gmail.com
mmcbain
Posts: 1
Joined: Fri Jun 02, 2023 8:11 am

Re: Compiling in MacBook with M1 processor

Post by mmcbain »

Hi, I was having issues similar to your while trying to compile. Between this post and the opensees documentation, I was able to find a process that worked for me. See pdf of instructions by following the link below. I'm pretty new to this, so open to hearing how the process might be improved. I have a Mac with Monterey 12.5, M1 processor and am working with openseespy locally.

https://compinlingopenseespy-macm1.tiiny.site
mhscott
Posts: 880
Joined: Tue Jul 06, 2004 3:38 pm
Location: Corvallis, Oregon USA
Contact:

Re: Compiling in MacBook with M1 processor

Post by mhscott »

mmcbain wrote: Fri Jun 02, 2023 8:22 am Hi, I was having issues similar to your while trying to compile. Between this post and the opensees documentation, I was able to find a process that worked for me. See pdf of instructions by following the link below. I'm pretty new to this, so open to hearing how the process might be improved. I have a Mac with Monterey 12.5, M1 processor and am working with openseespy locally.

https://compinlingopenseespy-macm1.tiiny.site
Thanks, @mmcbain! One note, you don't have to replace the .so file in the package folder. Instead, you can add the path in your scripts.

Code: Select all

import sys
sys.path.append('/path/to/opensees.so/')
import opensees as ops
It's kind of a pain to repeat these lines in your scripts, but it's safer than copying into the package folder and can avoid Python version issues.
Post Reply