dgasmith / gau2grid

Fast computation of a gaussian and its derivative on a grid.
https://gau2grid.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
29 stars 15 forks source link

Build problems with macOS + gcc #42

Closed maxscheurer closed 5 years ago

maxscheurer commented 5 years ago

When trying to build gau2grid with gcc 8.2.0 on macOS, I get a lot of the following warnings

/tmp/gau2grid/build/gau2grid_deriv2.c: In function 'gg_collocation_L8_deriv2':
/tmp/gau2grid/build/gau2grid_pragma.h:35:62: warning: incompatible implicit declaration of built-in function 'aligned_alloc'
     #define ALIGNED_MALLOC(alignment, size)                  aligned_alloc(alignment, size)
                                                              ^~~~~~~~~~~~~
/tmp/gau2grid/build/gau2grid_deriv2.c:5637:51: note: in expansion of macro 'ALIGNED_MALLOC'
     double* PRAGMA_RESTRICT cache_data = (double*)ALIGNED_MALLOC(64, 256 * sizeof(double));
                                                   ^~~~~~~~~~~~~~
/tmp/gau2grid/build/gau2grid_pragma.h:35:62: note: include '<stdlib.h>' or provide a declaration of 'aligned_alloc'
     #define ALIGNED_MALLOC(alignment, size)                  aligned_alloc(alignment, size)

finally resulting in a linker error:

Undefined symbols for architecture x86_64:
  "_aligned_alloc", referenced from:
      _gg_collocation_L0 in gau2grid_phi.c.o
      _gg_collocation_L1 in gau2grid_phi.c.o
      _gg_collocation_L2 in gau2grid_phi.c.o
      _gg_collocation_L3 in gau2grid_phi.c.o
      _gg_collocation_L4 in gau2grid_phi.c.o
      _gg_collocation_L5 in gau2grid_phi.c.o
      _gg_collocation_L6 in gau2grid_phi.c.o
      ...
ld: symbol(s) not found for architecture x86_64

I tried to include <stdlib.h> in the respective file, but it did not seem to work. Any ideas on this issue?

dgasmith commented 5 years ago

Hmm, I still cannot reproduce this. I would love to help, but no luck. How did you acquire GCC?

BTW, in general we discourage GCC on Mac due to the poor toolchain. We always very much emphasize clang.

maxscheurer commented 5 years ago

I installed it through Homebrew... I'll close this issue since it's not reproducible. As you say, it works fine with clang.

wadejong commented 5 years ago

This is reproducible.

cmake -H. -Bbuild -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 -DCMAKE_Fortran_COMPILER=gfortran-8

Homebrew installed gcc-8

Components of NWChemEx cannot compile properly with clang, hence we are using gcc on a Mac right now. Not clear where it goes wrong. Most likely the path to the include file is not found?

Bert