code-saturne / code_saturne

code_saturne public mirror
https://www.code-saturne.org
GNU General Public License v2.0
215 stars 80 forks source link

Cannot run on macOS #124

Open paspro opened 9 months ago

paspro commented 9 months ago

I am trying to run a simple case which has no user coding but code_saturne fails to do so during the compilation step of two user coding files created automatically by the system. The log is the following:


51 |       cs_lnum_t c_id = elt_ids[e_id];
      |                 ^~~~
/Users/panos/Runs/code_saturne/SIMPLE_PRISME_COLD_RING/OPEN_SPACE/RESU/20231011-1201/src/cs_meg_initialization.c:68:17: warning: unused variable 'c_id' [-Wunused-variable]
   68 |       cs_lnum_t c_id = elt_ids[e_id];
      |                 ^~~~
/Users/panos/Runs/code_saturne/SIMPLE_PRISME_COLD_RING/OPEN_SPACE/RESU/20231011-1201/src/cs_meg_initialization.c:36:40: warning: unused parameter 'xyz' [-Wunused-parameter]
   36 |                       const cs_real_t  xyz[][3],
      |                       ~~~~~~~~~~~~~~~~~^~~~~~~~
/Users/panos/Runs/code_saturne/SIMPLE_PRISME_COLD_RING/OPEN_SPACE/RESU/20231011-1201/src/cs_meg_boundary_function.c: In function 'cs_meg_boundary_function':
/Users/panos/Runs/code_saturne/SIMPLE_PRISME_COLD_RING/OPEN_SPACE/RESU/20231011-1201/src/cs_meg_boundary_function.c:53:17: warning: unused variable 'b_e_id' [-Wunused-variable]
   53 |       cs_lnum_t b_e_id = elt_ids[e_id];
      |                 ^~~~~~
/Users/panos/Runs/code_saturne/SIMPLE_PRISME_COLD_RING/OPEN_SPACE/RESU/20231011-1201/src/cs_meg_boundary_function.c:36:44: warning: unused parameter 'xyz' [-Wunused-parameter]
   36 |                          const cs_real_t   xyz[][3],
      |                          ~~~~~~~~~~~~~~~~~~^~~~~~~~
Undefined symbols for architecture arm64:
  "_bft_mem_malloc", referenced from:
      _cs_meg_initialization in cs_meg_initialization.o
      _cs_meg_boundary_function in cs_meg_boundary_function.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
/opt/homebrew/bin/mpicc -DHAVE_CONFIG_H -I/Users/panos/Applications/code_saturne/code_saturne-v8/include -I/Users/panos/Applications/code_saturne/code_saturne-v8/include/code_saturne -I/Users/panos/Applications/libs/COOLPROP/include -I/Users/panos/Applications/libs/CGNS/include -I/Users/panos/Applications/libs/MED/include -I/Users/panos/Applications/libs/HDF5/include -I/opt/homebrew/Cellar/petsc/3.20.0/include -I/Users/panos/Applications/libs/PARMETIS/include -I/Users/panos/Applications/libs/SCOTCH/include -DOMPI_SKIP_MPICXX -I/opt/homebrew/opt/openblas/include -I/opt/homebrew/opt/qt@5/include -D_DARWIN_C_SOURCE -DNDEBUG -funsigned-char -W -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wunused -Wfloat-equal -Werror=implicit-function-declaration -Wmisleading-indentation -Wduplicated-cond -fdiagnostics-color=auto -Werror=format-security -O3 -fopenmp -O2 -fexcess-precision=fast -c /Users/panos/Runs/code_saturne/SIMPLE_PRISME_COLD_RING/OPEN_SPACE/RESU/20231011-1201/src/cs_meg_initialization.c
/opt/homebrew/bin/mpicc -DHAVE_CONFIG_H -I/Users/panos/Applications/code_saturne/code_saturne-v8/include -I/Users/panos/Applications/code_saturne/code_saturne-v8/include/code_saturne -I/Users/panos/Applications/libs/COOLPROP/include -I/Users/panos/Applications/libs/CGNS/include -I/Users/panos/Applications/libs/MED/include -I/Users/panos/Applications/libs/HDF5/include -I/opt/homebrew/Cellar/petsc/3.20.0/include -I/Users/panos/Applications/libs/PARMETIS/include -I/Users/panos/Applications/libs/SCOTCH/include -DOMPI_SKIP_MPICXX -I/opt/homebrew/opt/openblas/include -I/opt/homebrew/opt/qt@5/include -D_DARWIN_C_SOURCE -DNDEBUG -funsigned-char -W -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wunused -Wfloat-equal -Werror=implicit-function-declaration -Wmisleading-indentation -Wduplicated-cond -fdiagnostics-color=auto -Werror=format-security -O3 -fopenmp -O2 -fexcess-precision=fast -c /Users/panos/Runs/code_saturne/SIMPLE_PRISME_COLD_RING/OPEN_SPACE/RESU/20231011-1201/src/cs_meg_boundary_function.c
/opt/homebrew/bin/mpic++ -o /Users/panos/Runs/code_saturne/SIMPLE_PRISME_COLD_RING/OPEN_SPACE/RESU/20231011-1201/cs_solver cs_meg_initialization.o cs_meg_boundary_function.o -lcs_solver -L/Users/panos/Applications/code_saturne/code_saturne-v8/lib -L/Users/panos/Applications/libs/COOLPROP/lib -L/Users/panos/Applications/libs/CGNS/lib -L/Users/panos/Applications/libs/MED/lib -L/Users/panos/Applications/libs/HDF5/lib -L/Users/panos/Applications/libs/PARMETIS/lib -L/Users/panos/Applications/libs/SCOTCH/lib -L/opt/homebrew/opt/openblas/lib -Wl,-rpath -Wl,:/Users/panos/Applications/code_saturne/code_saturne-v8/lib -O -fopenmp -lsaturne -lple -lCoolProp -lcgns -lmedC -lhdf5 -Wl,-rpath,/opt/homebrew/Cellar/petsc/3.20.0/lib -L/opt/homebrew/Cellar/petsc/3.20.0/lib -Wl,-rpath,/opt/homebrew/Cellar/open-mpi/4.1.5/lib -L/opt/homebrew/Cellar/open-mpi/4.1.5/lib -Wl,-rpath,/opt/homebrew/opt/hwloc/lib -L/opt/homebrew/opt/hwloc/lib -Wl,-rpath,/opt/homebrew/opt/libevent/lib -L/opt/homebrew/opt/libevent/lib -Wl,-rpath,/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13 -Wl,-rpath,/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc -Wl,-rpath,/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current -L/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current -lpetsc -llapack -lblas -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi -lgfortran -ld_classic -lgfortran -lemutls_w -lquadmath -lc++ -lparmetis -lmetis -lptscotch -lscotch -lcblas -lblas -lz -ldl -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi -lgfortran -lemutls_w -lquadmath -lm -Wl,-rpath -Wl,:/Users/panos/Applications/code_saturne/code_saturne-v8/lib:/Users/panos/Applications/libs/COOLPROP/lib:/Users/panos/Applications/libs/CGNS/lib:/Users/panos/Applications/libs/MED/lib:/Users/panos/Applications/libs/HDF5/lib:/Users/panos/Applications/libs/PARMETIS/lib:/Users/panos/Applications/libs/SCOTCH/lib:/opt/homebrew/opt/openblas/lib:/opt/homebrew/Cellar/petsc/3.20.0/lib:/opt/homebrew/Cellar/open-mpi/4.1.5/lib:/opt/homebrew/opt/hwloc/lib:/opt/homebrew/opt/libevent/lib:/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13:/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc:/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current:/opt/homebrew/Cellar/open-mpi/4.1.5/lib:/opt/homebrew/opt/libevent/lib:/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13:/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc:/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current
paspro commented 9 months ago

The problem for this is the fact that libsaturne-8.0.dylib, which is the dynamic library of code_saturne, contains no symbols

nm -g libsaturne-8.0.dylib
libsaturne-8.0.dylib: no symbols

which means that it is not created properly. The problem can be resolved if I change the configuration settings with the flags:

--enable-static
--disable-shared

in which case the static version of this library is created (libsaturne.a) and this file is correctly made. Note that this way of working on macOS is preferable when the SIP (System Integrity Protection) option is enabled and user coding is present for a case since SIP does not allow the bypassing of the application's code with other code dynamically which is needed for the user coding to bypass the empty user functions. Nevertheless, there is a problem with the linking process of this library.

YvanFournier commented 9 months ago

Hello,

Regarding the symbols in the dylib, if any Mac user finds the correct options for building the library, I will be happy to integrate it (though it is a pain the Apple breaks compatibility every other version).