I've been beating my head against a wall for the past week trying to get a project to compile on my M1 Mac Mini (macOS Big Sur 11.4). Posting here rather than as an issue on the project Github page because this seems like a general toolchain issue. (Side note, I was able to compile the same code without any issues on my Win10 machine under WSL2 with a Debian-based distro and all the dependencies installed via apt-get)
Error (one of many, but all related to the long long variation of functions):
In file included from include/trick/Clock.hh:11:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/string:506:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/string_view:175:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/algorithm:643:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/exception:81:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/cstdlib:85:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/stdlib.h:148:12: error: no member named 'lldiv' in the global namespace; did you mean 'ldiv'?
return ::lldiv(__x, __y);
I've tried following the advice from some comments in this thread but none have helped.
- Installed XCode.app, changed the SDK path, and removed the CLT directory (I've since reverted to only having the CLT installed)
- Added
set(CMAKE_OSX_SYSROOT /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk)
to the project'sCMakeLists.txt
- Explicitly setting clang, gcc, g++, etc... as the compiler in the
./configure
flags - Explicitly including
-I/path/to/MacOSX.sdk/usr/include
in the CXXFLAGS set in ./configure
eric@Mac-Wahlberg ~
╰─$ clang -v 1 ↵
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
╭─eric@Mac-Wahlberg ~
╰─$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
╭─eric@Mac-Wahlberg ~
╰─$ g++ -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
╭─eric@Mac-Wahlberg ~
╰─$ xcrun --sdk macosx --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
eric@Mac-Wahlberg ~/Code/trick ‹15534f7›
╰─$ gcc -Wp,-v -E -
clang -cc1 version 12.0.5 (clang-1205.0.22.11) default target arm64-apple-darwin20.5.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
Some more terminal copypasta that may or may not be useful
╭─eric@Mac-Wahlberg ~/Code/trick ‹15534f7*›
╰─$ cat /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/C++/v1/stdlib.h | grep "lldiv"
lldiv_t // C99
lldiv_t div(long long numer, long long denom); // C++0X
lldiv_t lldiv(long long numer, long long denom); // C99
#undef lldiv
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
return ::lldiv(__x, __y);