'Compile error on Mac : undeclared identifier 'LC_COLLATE_MASK

Hi I have wanted to build my C++ project using CMake on my Mac M1 Pro 12.0.1.

I am using following CMake command :

cmake .. -DCMAKE_CXX_FLAGS="-Werror=return-type -Wno-pragmas -DBOOST_THREAD_PROVIDES_FUTURE=1 -DBOOST_THREAD_PROVIDES_FUTURE_CONTINUATION=1 -DJPEG_DISABLE_OPTIM=1 -D_FILE_OFFSET_BITS=32 -mno-unaligned-access -Wno-extern-c-compat -Qunused-arguments -Wno-conversion-null -fexceptions -frtti -std=c++14 -DES_ENABLE_LOGGING=1"

But I am getting a ton of compiler errors in C++ header files:

In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/sstream:184:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/ostream:137:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/ios:215:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:136:20: error: use of undeclared identifier 'LC_COLLATE_MASK'
        collate  = LC_COLLATE_MASK,
                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:137:20: error: use of undeclared identifier 'LC_CTYPE_MASK'
        ctype    = LC_CTYPE_MASK,
                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:138:20: error: use of undeclared identifier 'LC_MONETARY_MASK'
        monetary = LC_MONETARY_MASK,
                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:139:20: error: use of undeclared identifier 'LC_NUMERIC_MASK'
        numeric  = LC_NUMERIC_MASK,
                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:140:20: error: use of undeclared identifier 'LC_TIME_MASK'
        time     = LC_TIME_MASK,
                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:141:20: error: use of undeclared identifier 'LC_MESSAGES_MASK'
        messages = LC_MESSAGES_MASK,
                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:353:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:125:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:372:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:125:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:752:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:125:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:770:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:125:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__locale:1002:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;

I searched on internet about this but still didn't get any solution. Am I missing something in my CMake arguments or on my Mac?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source