MacOS Catalina 10.15.5 compilation error

Hi everyone,

I am experiencing compilation errors.

herzc@54ee75c68e2e ~/D/S4D> /Library/Developer/CommandLineTools/usr/bin/gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

cmake version 3.18.1

Here some preview of the error messages:

/usr/local/include/stdlib.h:141:26: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
void    *bsearch(const void *__key, const void *__base, size_t __nel,
                            ^
/usr/local/include/stdlib.h:141:26: note: insert '_Nullable' if the pointer may be null
void    *bsearch(const void *__key, const void *__base, size_t __nel,
                            ^
                              _Nullable 
/usr/local/include/stdlib.h:141:26: note: insert '_Nonnull' if the pointer should never be null
void    *bsearch(const void *__key, const void *__base, size_t __nel,
                            ^
                              _Nonnull 
/usr/local/include/stdlib.h:141:45: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
void    *bsearch(const void *__key, const void *__base, size_t __nel,
                                               ^
/usr/local/include/stdlib.h:141:45: note: insert '_Nullable' if the pointer may be null
void    *bsearch(const void *__key, const void *__base, size_t __nel,
                                               ^
                                                 _Nullable 
/usr/local/include/stdlib.h:141:45: note: insert '_Nonnull' if the pointer should never be null
void    *bsearch(const void *__key, const void *__base, size_t __nel,
                                               ^
                                                 _Nonnull 
fatal error: too many errors emitted, stopping now [-ferror-limit=]

I uploaded a gist here https://gist.github.com/che85/9cec7d8e0b2a4ada61ff553e51f3c567

Does anyone know how to fix these issues? I haven’t seen any recent changes which could have affected the build process and even tried older versions.

I already removed XCode and reinstalled CommandLineTools, but nothing changed.

There were some libarchive related fixes réce tly that might not have made it into Slicer yet. @pieper can you confirm? Is there a quick fix?

I don’t get these errors on my mac build. How do you configure?

This is what I did:

cmake \
	-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
	Qt5_VERSION:STRING=5.15 \
	Qt5_DIR:PATH=/usr/local/Cellar/qt/5.15.0/lib/cmake/Qt5 \
	/Users/pieper/slicer/latest/Slicer

Similar to yours:

cmake \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
-DQt5_VERSION:STRING=5.15 \
-DQt5_DIR:PATH=/usr/local/Cellar/qt/5.15.0/lib/cmake/Qt5 \
~/sources/cpp/Slicer

@pieper What are you getting when entering ls -la /usr/local/include/stdlib.h

herzc@54ee75c68e2e ~/s/c/l/bld> ls -la /usr/local/include/stdlib.h
lrwxr-xr-x  1 root  admin  72 Jul 23 23:53 /usr/local/include/stdlib.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h

@pieper Do you have the same clang version?

I think there were some headerfiles messsed up on my mac. I think it’s working now. I removed all headerfiles from /usr/local/include that were pointing to /Library/Developer/CommandLineTools

1 Like

Glad it worked :+1:

In case anyone looks in the future, I’ve got a brand new mac (like a week old) with the latest OS and Xcode and the build went smoothly.

% ls -la /usr/local/include/stdlib.h     
ls: /usr/local/include/stdlib.h: No such file or directory