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.
Andrew
Posts: 13
Joined: Wed Apr 06, 2005 7:28 pm
Location: Arup

Re: Compiling in MacBook with M1 processor

Post by Andrew »

Thank you for this. I have been trying to follow it, and while the compiling finishes for `mumps`, there are a lot of warnings about `Type mismatch`. Any idea why this should be? Is it a problem? I am compiling on a MacBookAir with an M2 chip running Sequoia 15.2. `brew` installed Python 3.13. Could this be a problem?
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

Code: Select all

% cmake --build . --config Release --parallel 4
[  1%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/graph.c.o
[  1%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/gbisect.c.o
[  3%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/gbipart.c.o
[  3%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/ddcreate.c.o
[  3%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/ddbisect.c.o
[  5%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/nestdiss.c.o
[  5%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/multisector.c.o
[  5%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/gelim.c.o
[  5%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/tree.c.o
[  6%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/bucket.c.o
[  7%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/symbfac.c.o
[  8%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/interface.c.o
[  8%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/sort.c.o
[  9%] Building C object _deps/mumps-build/pord/lib/CMakeFiles/pord.dir/minpriority.c.o
[ 10%] Linking C static library ../../../../libpord.a
[ 10%] Built target pord
[ 10%] Building Fortran object _deps/mumps-build/src/CMakeFiles/mumps_common.dir/double_linked_list.F.o
[ 10%] Building Fortran object _deps/mumps-build/src/CMakeFiles/mumps_common.dir/ana_blk_m.F.o
[ 11%] Building Fortran object _deps/mumps-build/src/CMakeFiles/mumps_common.dir/ana_orderings_wrappers_m.F.o
[ 11%] Building Fortran object _deps/mumps-build/src/CMakeFiles/mumps_common.dir/omp_tps_common_m.F.o
/Users/andrew/Documents/GitHub/mumps/build/_deps/mumps-src/src/ana_orderings_wrappers_m.F:1025:35:

  997 |      &                             NV, NCMPA, int(N,8) )
      |                                   2
......
 1025 |      &                             NV8, NCMPA, int(N,8) )
      |                                   1
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/INTEGER(4)).
/Users/andrew/Documents/GitHub/mumps/build/_deps/mumps-src/src/ana_orderings_wrappers_m.F:1028:45:

  996 |      &                             XADJ8(1), IW(1),
      |                                             2
......
 1028 |      &                             XADJ8(1), IW8,
      |                                             1
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/INTEGER(4)).
/Users/andrew/Documents/GitHub/mumps/build/_deps/mumps-src/src/ana_orderings_wrappers_m.F:1033:32:

  998 |         CALL MUMPS_ICOPY_64TO32(XADJ8(1), NVTX, PARENT)
      |                                2
......
 1033 |         CALL MUMPS_ICOPY_64TO32(NV8, NVTX, NV)
      |                                1
Warning: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
/Users/andrew/Documents/GitHub/mumps/build/_deps/mumps-src/src/ana_orderings_wrappers_m.F:965:28:

  965 |       CALL MUMPS_PORDF_WND( NVTX, int(NEDGES8),
      |                            1
......
  995 |         CALL MUMPS_PORDF_WND( int(NVTX,8), NEDGES8,
      |                              2
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/INTEGER(8)).
/Users/andrew/Documents/GitHub/mumps/build/_deps/mumps-src/src/ana_orderings_wrappers_m.F:965:34:

  965 |       CALL MUMPS_PORDF_WND( NVTX, int(NEDGES8),
      |                                  1
......
  995 |         CALL MUMPS_PORDF_WND( int(NVTX,8), NEDGES8,
      |                                           2

And then, when I try to build OpenSees, I get a CMake error:

Code: Select all

% cmake .. -DMUMPS_DIR=$PWD/../../mumps/build -DOPENMPI=TRUE -DSCALAPACK_LIBRARIES=/opt/homebrew/lib/libscalapack.dylib
-- The C compiler identification is AppleClang 16.0.0.16000026
-- The CXX compiler identification is AppleClang 16.0.0.16000026
-- The Fortran compiler identification is GNU 14.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/homebrew/bin/gfortran - skipped
-- Found MPI_C: /opt/homebrew/Cellar/open-mpi/5.0.6/lib/libmpi.dylib (found version "3.1")
-- Found MPI_CXX: /opt/homebrew/Cellar/open-mpi/5.0.6/lib/libmpi.dylib (found version "3.1")
-- Found MPI_Fortran: /opt/homebrew/Cellar/open-mpi/5.0.6/lib/libmpi_usempif08.dylib (found version "3.1")
-- Found MPI: TRUE (found version "3.1")
COMPILER: Clang
/Users/andrew/Documents/GitHub/OpenSees/build
NOT USING CONAN
-- Found HDF5: hdf5-shared (found version "1.14.5")
-- Found Tclsh: /usr/bin/tclsh (found version "8.5")
-- Found TCL: /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/tcl.framework
-- Found TCLTK: /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/tcl.framework
-- Found TK: /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/tk.framework
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION - Failed
-- MySQL not found.
-- MySQL Embedded not found.
-- Found HDF5: hdf5-static (found version "1.14.5")
-- HDF5 found version: 1.14.5
-- HDF5_CXX_DEFINITIONS = 
-- HDF5_LIBRARIES = hdf5-static
-- HDF5 VERSION OLD: 1.14.5
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Looking for Fortran dgemm
-- Looking for Fortran dgemm - found
-- Found BLAS: /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/Accelerate.framework
-- Looking for Fortran cheev
-- Looking for Fortran cheev - found
-- Found LAPACK: /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/Accelerate.framework;-lm;-ldl
-- Found Python: /opt/homebrew/Frameworks/Python.framework/Versions/3.13/bin/python3.13 (found version "3.13.1") found components: Interpreter Development Development.Module Development.Embed
CMake Warning at CMakeLists.txt:310 (find_package):
  By not providing "FindMKL.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "MKL", but
  CMake did not find one.

  Could not find a package configuration file provided by "MKL" with any of
  the following names:

    MKLConfig.cmake
    mkl-config.cmake

  Add the installation prefix of "MKL" to CMAKE_PREFIX_PATH or set "MKL_DIR"
  to a directory containing one of the above files.  If "MKL" provides a
  separate development package or SDK, be sure it has been installed.


-- LAPACK was found.
-- LAPACK_LINKER_FLAGS = 
-- LAPACK_LIBRARIES = /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/Accelerate.framework;-lm;-ldl
Python_FOUND:TRUE
Python_LIBRARIES:/opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/lib/libpython3.13.dylib
Python_INCLUDES:/opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/include/python3.13
-- MPI was found.
-- MPI was found .. path added /opt/homebrew/Cellar/open-mpi/5.0.6/include TRUE
-- MKL NOT found .. user to provide -DSCALAPACK_LIBRARIES=
-- SCALAPACK_LIBRARIES=/opt/homebrew/lib/libscalapack.dylib
OPS >>> Configuring OpenSees extensions
-- OPS >>> Have HDF5 and VERSION >= 1.12.0
-- Configuring done (5.0s)
CMake Error at /opt/homebrew/lib/cmake/hdf5/hdf5-targets.cmake:61 (set_target_properties):
  The link interface of target "hdf5-static" contains:

    ZLIB::ZLIB

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /opt/homebrew/lib/cmake/hdf5/hdf5-config.cmake:174 (include)
  /opt/homebrew/share/cmake/Modules/FindHDF5.cmake:513 (find_package)
  CMakeLists.txt:113 (find_package)


-- Generating done (1.5s)
CMake Warning:
  Manually-specified variables were not used by the project:

    OPENMPI


CMake Generate step failed.  Build files cannot be regenerated correctly.
I continued, and got lots of warnings, but only one error - `'Eigen/Dense' file not found`

Code: Select all

% cmake --build . --config Release --target OpenSees --parallel 4

[...]

[ 97%] Building CXX object CMakeFiles/OPS_Material.dir/SRC/material/section/DoubleMembranePlateFiberSection.cpp.o
In file included from /Users/andrew/Documents/GitHub/OpenSees/SRC/material/nD/ASDPlasticMaterial3D/OPS_AllASDPlasticMaterial3Ds.cpp:33:
In file included from /Users/andrew/Documents/GitHub/OpenSees/SRC/material/nD/ASDPlasticMaterial3D/AllASDPlasticMaterial3Ds.h:28:
In file included from /Users/andrew/Documents/GitHub/OpenSees/SRC/material/nD/ASDPlasticMaterial3D/ASDPlasticMaterial3D.h:42:
In file included from /Users/andrew/Documents/GitHub/OpenSees/SRC/material/nD/ASDPlasticMaterial3D/ASDPlasticMaterial3DGlobals.h:31:
/Users/andrew/Documents/GitHub/OpenSees/OTHER/eigenAPI/EigenAPI.h:48:10: fatal error: 'Eigen/Dense' file not found
   48 | #include "Eigen/Dense"
      |          ^~~~~~~~~~~~~
[ 97%] Building CXX object CMakeFiles/OPS_Material.dir/SRC/material/section/ElasticBDShearSection2d.cpp.o
1 error generated.
make[3]: *** [CMakeFiles/OPS_Material.dir/SRC/material/nD/ASDPlasticMaterial3D/OPS_AllASDPlasticMaterial3Ds.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/OPS_Material.dir/all] Error 2
make[1]: *** [CMakeFiles/OpenSees.dir/rule] Error 2
make: *** [OpenSees] Error 2
I continued and ended up with essentially the same error:

Code: Select all

% cmake --build . --config Release --target OpenSeesPy
[  0%] Built target OPS_SysOfEqn_f
[  0%] Built target OPS_Matrix
[  1%] Built target OPS_Actor
[  1%] Built target OPS_ObjectBroker
[  1%] Built target OPS_Handler
[  2%] Built target OPS_Recorder
[ 10%] Built target OPS_Reliability
[ 11%] Built target OPS_Tagged
[ 11%] Built target OPS_Utilities
[ 11%] Built target OPS_ModelBuilder
[ 16%] Built target OPS_Domain
[ 20%] Built target OPS_SysOfEqn
[ 20%] Built target OPS_Analysis_Naccel
[ 27%] Built target OPS_Analysis
[ 27%] Built target OPS_ConvergenceTest
[ 27%] Built target OPS_Thermal
[ 43%] Built target OPS_Element
[ 45%] Built target OPS_ElementFortran
[ 46%] Built target OPS_Material_nD_Feap_f
[ 46%] Built target OPS_Material_f
[ 46%] Built target OPS_Material_Uniaxial_Drain_f
[ 46%] Building CXX object CMakeFiles/OPS_Material.dir/SRC/material/nD/ASDPlasticMaterial3D/OPS_AllASDPlasticMaterial3Ds.cpp.o
In file included from /Users/andrew/Documents/GitHub/OpenSees/SRC/material/nD/ASDPlasticMaterial3D/OPS_AllASDPlasticMaterial3Ds.cpp:33:
In file included from /Users/andrew/Documents/GitHub/OpenSees/SRC/material/nD/ASDPlasticMaterial3D/AllASDPlasticMaterial3Ds.h:28:
In file included from /Users/andrew/Documents/GitHub/OpenSees/SRC/material/nD/ASDPlasticMaterial3D/ASDPlasticMaterial3D.h:42:
In file included from /Users/andrew/Documents/GitHub/OpenSees/SRC/material/nD/ASDPlasticMaterial3D/ASDPlasticMaterial3DGlobals.h:31:
/Users/andrew/Documents/GitHub/OpenSees/OTHER/eigenAPI/EigenAPI.h:48:10: fatal error: 'Eigen/Dense' file not found
   48 | #include "Eigen/Dense"
      |          ^~~~~~~~~~~~~
1 error generated.
make[3]: *** [CMakeFiles/OPS_Material.dir/SRC/material/nD/ASDPlasticMaterial3D/OPS_AllASDPlasticMaterial3Ds.cpp.o] Error 1
make[2]: *** [CMakeFiles/OPS_Material.dir/all] Error 2
make[1]: *** [CMakeFiles/OpenSeesPy.dir/rule] Error 2
make: *** [OpenSeesPy] Error 2
No `dylib` files were generated.
Post Reply