Build failing on MacOS 15.2 (M1)
Dear developers,
I am installing Hermes-3 (along with its automatic download of BOUT-dev) on my personal laptop (M1 Mac) running macOS 15.2.
I have executed the cmake command:
$ cmake . -B build -DBOUT_DOWNLOAD_SUNDIALS=ON -DBOUT_ENABLE_BACKTRACE=Off -DCMAKE_OSX_ARCHITECTURES=arm64
then built it by $ cmake --build build
However, it is quite tricky for me to solve the issue below:
[ 13%] Built target pvode
[ 14%] Building CXX object external/BOUT-dev/externalpackages/PVODE/CMakeFiles/pvpre.dir/precon/pvbbdpre.cpp.o
[ 14%] Building CXX object external/BOUT-dev/externalpackages/PVODE/CMakeFiles/pvpre.dir/precon/band.cpp.o
[ 14%] Linking CXX shared library ../../lib/libpvpre.dylib
Undefined symbols for architecture arm64:
"pvode::N_VWrmsNorm(pvode::nvec_type*, pvode::nvec_type*)", referenced from:
pvode::PVBBDPrecon(int, double, pvode::nvec_type*, pvode::nvec_type*, int, int*, double, pvode::nvec_type*, double, double, long*, void*, pvode::nvec_type*, pvode::nvec_type*, pvode::nvec_type*) in pvbbdpre.cpp.o
"pvode::RSqrt(double)", referenced from:
pvode::PVBBDPrecon(int, double, pvode::nvec_type*, pvode::nvec_type*, int, int*, double, pvode::nvec_type*, double, double, long*, void*, pvode::nvec_type*, pvode::nvec_type*, pvode::nvec_type*) in pvbbdpre.cpp.o
"pvode::N_VScale(double, pvode::nvec_type*, pvode::nvec_type*)", referenced from:
pvode::PVBBDPrecon(int, double, pvode::nvec_type*, pvode::nvec_type*, int, int*, double, pvode::nvec_type*, double, double, long*, void*, pvode::nvec_type*, pvode::nvec_type*, pvode::nvec_type*) in pvbbdpre.cpp.o
pvode::PVBBDPSol(int, double, pvode::nvec_type*, pvode::nvec_type*, pvode::nvec_type*, double, pvode::nvec_type*, double, long*, pvode::nvec_type*, int, void*, pvode::nvec_type*) in pvbbdpre.cpp.o
ld: symbol(s) not found for architecture arm64
c++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [external/BOUT-dev/lib/libpvpre.1.0.0.dylib] Error 1
make[1]: *** [external/BOUT-dev/externalpackages/PVODE/CMakeFiles/pvpre.dir/all] Error 2
make: *** [all] Error 2
I will appreciate if you could point me how to address this. Thank you!
Welcome @sun51027 ! This is interesting; You may be the first person to try this on an M1 laptop :)
What happens if you don't specify the architecture? The system compiler should compile for the system architecture so this may work (?):
cmake . -B build -DBOUT_DOWNLOAD_SUNDIALS=ON -DBOUT_ENABLE_BACKTRACE=Off
I have an old Mac, and often have problems with shared libraries (like this .dylib). One thing you can try is disabling shared libraries (using -DBUILD_SHARED_LIBS=Off) and other things that can go wrong on MacOS:
cmake . -B build -DBOUT_DOWNLOAD_SUNDIALS=ON -DBOUT_ENABLE_BACKTRACE=Off -DBUILD_SHARED_LIBS=Off -DBOUT_USE_NLS=Off -DBOUT_USE_UUID_SYSTEM_GENERATOR=Off
Hi @bendudson, thank you for your prompt response.
The second command you gave worked until the new error below:
[ 42%] Building CXX object external/BOUT-dev/CMakeFiles/bout++.dir/src/mesh/mesh.cxx.o
[ 44%] Building CXX object external/BOUT-dev/CMakeFiles/bout++.dir/src/mesh/parallel/fci.cxx.o
/Users/zero/workspace/phd_work/hermes-3/external/BOUT-dev/src/mesh/parallel/fci.cxx:295:13: error: no matching function for call to 'finite'
295 | ASSERT2(finite(result[inext]));
| ^~~~~~
/Users/zero/workspace/phd_work/hermes-3/external/BOUT-dev/include/bout/assert.hxx:50:9: note: expanded from macro 'ASSERT2'
50 | if (!(condition)) { \
| ^~~~~~~~~
/Users/zero/workspace/phd_work/hermes-3/external/BOUT-dev/include/bout/field.hxx:632:13: note: candidate template ignored: requirement 'is_Field_v<double>' was not satisfied [with T = BoutReal]
632 | inline bool finite(const T& f, const std::string& rgn = "RGN_ALL") {
| ^
1 error generated.
make[2]: *** [external/BOUT-dev/CMakeFiles/bout++.dir/src/mesh/parallel/fci.cxx.o] Error 1
make[1]: *** [external/BOUT-dev/CMakeFiles/bout++.dir/all] Error 2
make: *** [all] Error 2
On the other hand, I’m also curious about what will happen if we disable shared libraries, such as how it might affect execution (?) Thank you :)
Ah, it seems we use are aware that finite is not-standard:
#ifdef _MSC_VER
// finite is not actually standard C++, it's a BSD extention for C
inline auto finite(BoutReal x) -> bool { return std::isfinite(x); }
So we just need to adjust the check above for whatever compiler you are using ...
Do you know how to check for that compiler?
Oh, we should probably just switch to the standard one anyway!
Hi @sun51027 ! Could you please try updating Hermes-3 (git pull should do it), then try configuring again? On my old (x86) mac this works:
cmake . -B build -DBOUT_DOWNLOAD_SUNDIALS=ON -DBOUT_ENABLE_BACKTRACE=Off -DBOUT_USE_NLS=Off -DBOUT_USE_UUID_SYSTEM_GENERATOR=Off
The latest BOUT++ had problems building on mac, that I think are now fixed https://github.com/boutproject/BOUT-dev/pull/3063
I updated Hermes-3 to use the latest BOUT++ version, that includes the new fixes: https://github.com/bendudson/hermes-3/pull/284
Hi @bendudson Thank you for the update and the new command. However, a new error pop up after I git pull Hermes-3.
[ 59%] Linking CXX shared library lib/libbout++.dylib
ld: library 'hdf5_hl-shared' not found
c++: error: linker command failed with exit code 1 (use -v to see invocation)
I’ve been trying to solve this for a while, but I still failed. Could you point out how to solve this? Thank you very much!