How to fix XCode invivisble Headers and Clang compiler issue in MacOS? - c++

GCC- Apple clang version 11.0.3 (clang-1103.0.32.29) is giving me weird results when I try to run any C++/C program. For example, running this code:
#include <string>
#include <iostream>
int main()
{
std::string hello = "Hello world";
std::cout << hello << std::endl;
return 0;
}
I run with gcc or g++
gcc template.cpp -o template
It gives me this error
In file included from template.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:439:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:624:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/initializer_list:47:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stddef.h:50:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__nullptr:23:29: error: variable has incomplete type 'struct _LIBCPP_TEMPLATE_VIS'
struct _LIBCPP_TEMPLATE_VIS nullptr_t
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__nullptr:23:8: note: forward declaration of 'std::__1::_LIBCPP_TEMPLATE_VIS'
struct _LIBCPP_TEMPLATE_VIS nullptr_t
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__nullptr:23:38: error: expected ';' after top level declarator
struct _LIBCPP_TEMPLATE_VIS nullptr_t
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__nullptr:46:52: error: unknown type name 'nullptr_t'
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
^
In file included from template.cpp:2:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:40:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/istream:163:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:140:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/locale:192:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:167:44: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:110:44: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:135:9: note: using declaration
using ::abs;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:169:44: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:112:44: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:135:9: note: using declaration
using ::abs;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:172:42: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:115:42: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:143:9: note: using declaration
using ::div;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:174:42: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:117:42: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:143:9: note: using declaration
using ::div;
^
7 errors generated.
I think I caused this when I was trying to copy some library header files to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
Now I am unable to compile any C++ program on my Mac. I can't understand how to fix this.
I tried installing llvm and adding it's path but nothing helps.
> brew install llvm
==> Installing dependencies for llvm: libffi
==> Installing llvm dependency: libffi
==> Downloading https://homebrew.bintray.com/bottles/libffi-3.3.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libffi-3.3.catalina.bottle.tar.gz
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
For compilers to find libffi you may need to set:
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export CPPFLAGS="-I/usr/local/opt/libffi/include"
For pkg-config to find libffi you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
==> Summary
đŸș /usr/local/Cellar/libffi/3.3: 16 files, 489.4KB
==> Installing llvm
==> Downloading https://homebrew.bintray.com/bottles/llvm-10.0.0_3.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ea/ea9b9f579df49499d9ab0084e10edecc5350298d6c5db399a1dabc8694dab7db?__gda__=exp=1587779777~hmac=fa0024a2581a685070cc1612da34abc29c53c8c352dce2f47c74d841c
######################################################################## 100.0%
==> Pouring llvm-10.0.0_3.catalina.bottle.tar.gz
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH run:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc
For compilers to find llvm you may need to set:
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
==> Summary
đŸș /usr/local/Cellar/llvm/10.0.0_3: 7,055 files, 1GB
> echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc
> export LDFLAGS="-L/usr/local/opt/llvm/lib"
> export CPPFLAGS="-I/usr/local/opt/llvm/include"
~
Current versions of installed Clang:
> gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.29)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
> g++ version

Well, I found a solution. Earlier I was using XCode Application and I messed up some library files when I was trying to copy header files to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
It turned so fatal that I was totally helpless. Neither my C++ or C code would compile, nor Node Applications would build due to gyp.
Apparently it some more errors, when I tried to reinstall few things and my homebrew gave a page full of errors with unbrewed header files.
Solution:
I removed Xcode Application, switched to Command line tool.
Removed llvm, and it worked.
You need to switch the XCode path, you do it by:
sudo xcode-select --switch /Library/Developer/CommandLineTools
You are good to go, and never mess up with the files inside SDK, else it will cost you hours of panic. Cheers.

I had to re-install the xcode tools for some weird reason...
sudo rm -rf $(xcode-select -print-path)
xcode-select --install

I had similar issues building a meteor app that had a node-gyp dependency, in the end I was able to follow the instructions here to get the build to work
Specifically exporting this flag:
export LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
The failure looked like
> bufferutil#4.0.4 install /Users/ben.ritchie/Documents/dev/connect4/connect4mvp/node_modules/bufferutil
> node-gyp-build
CC(target) Release/obj.target/bufferutil/src/bufferutil.o
In file included from ../src/bufferutil.c:2:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:42:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:52:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
#error architecture not supported
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:52:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
typedef __int64_t __darwin_blkcnt_t; /* total blocks */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'
typedef __int32_t __darwin_blksize_t; /* preferred block size */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'
typedef __int32_t __darwin_dev_t; /* dev_t */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_gid_t; /* [???] process and group IDs */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_id_t; /* [XSI] pid_t, uid_t, or gid_t*/
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'; did you mean 'uint64_t'?
typedef __uint64_t __darwin_ino64_t; /* [???] Used for 64 bit inodes */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uint64_t.h:31:28: note: 'uint64_t' declared here
typedef unsigned long long uint64_t;
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:52:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'
typedef __uint16_t __darwin_mode_t; /* [???] Some file attributes */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
typedef __int64_t __darwin_off_t; /* [???] Used for file sizes */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t'
typedef __int32_t __darwin_pid_t; /* [???] process and group IDs */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_sigset_t; /* [???] signal set */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t'
typedef __int32_t __darwin_suseconds_t; /* [???] microseconds */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_uid_t; /* [???] user IDs */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_useconds_t; /* [???] microseconds */
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:53:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_intptr_t.h:30:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/types.h:37:2: error: architecture not supported
#error architecture not supported
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:53:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_intptr_t.h:32:9: error: unknown type name '__darwin_intptr_t'
typedef __darwin_intptr_t intptr_t;
^
18 errors generated.
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/ben.ritchie/.meteor/packages/meteor-tool/.2.5.0.sgqk5k.nggn++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/bin/node" "/Users/ben.ritchie/.meteor/packages/meteor-tool/.2.5.0.sgqk5k.nggn++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/ben.ritchie/Documents/dev/connect4/connect4mvp/node_modules/bufferutil
gyp ERR! node -v v12.20.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok

Just change:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1

Related

R packages installations give a `::std::isxdigit' declared here fatal error`

I recently updated the Homebrew on my Mac (10.14.6 (18G6020)), and went ahead to recompile the development version of R. I built an installation script to make sure the same steps are taken every time (see below). R compiles successfully and passes all checks. However, when I begin to install packages, such as Rcpp, devtools, ape, lme4, among others, I get a ::std::isxdigit declared here during the compilation, and installation fails.
I'm posting here the error message for Rcpp, installation script, sessionInfo(), and brew version. Any help to resolve this will be much appreciated,
Thank you !
Error message for Rcpp:
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I../inst/include/ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr\
/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pa\
ngo-1.0/pango -I/usr/local/opt/tcl-tk/include -fPIC -Wall -g -O3 -c api.cpp -o api.o
In file included from api.cpp:24:
In file included from ../inst/include/Rcpp.h:27:
In file included from ../inst/include/RcppCommon.h:51:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream:38:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/ios:216:
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:116:20: error: use
of undeclared identifier 'LC_COLLATE_MASK'
collate = LC_COLLATE_MASK,
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:117:20: error: use
of undeclared identifier 'LC_CTYPE_MASK'
ctype = LC_CTYPE_MASK,
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:118:20: error: use
of undeclared identifier 'LC_MONETARY_MASK'
monetary = LC_MONETARY_MASK,
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:119:20: error: use
of undeclared identifier 'LC_NUMERIC_MASK'
numeric = LC_NUMERIC_MASK,
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:120:20: error: use
of undeclared identifier 'LC_TIME_MASK'
time = LC_TIME_MASK,
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:121:20: error: use
of undeclared identifier 'LC_MESSAGES_MASK'
messages = LC_MESSAGES_MASK,
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:330:5: error:
unknown type name 'locale_t'; did you mean 'locale'?
locale_t __l;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:105:24: note:
'locale' declared here
class _LIBCPP_TYPE_VIS locale
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:349:5: error:
unknown type name 'locale_t'; did you mean 'locale'?
locale_t __l;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:105:24: note:
'locale' declared here
class _LIBCPP_TYPE_VIS locale
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:708:5: error:
unknown type name 'locale_t'; did you mean 'locale'?
locale_t __l;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:105:24: note:
'locale' declared here
class _LIBCPP_TYPE_VIS locale
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:726:5: error:
unknown type name 'locale_t'; did you mean 'locale'?
locale_t __l;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:105:24: note:
'locale' declared here
class _LIBCPP_TYPE_VIS locale
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:958:5: error:
unknown type name 'locale_t'; did you mean 'locale'?
locale_t __l;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:105:24: note:
'locale' declared here
class _LIBCPP_TYPE_VIS locale
^
In file included from api.cpp:24:
In file included from ../inst/include/Rcpp.h:27:
In file included from ../inst/include/RcppCommon.h:51:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream:40:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/istream:163:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/ostream:140:
/Library/Developer/CommandLineTools/usr/include/c++/v1/locale:739:26: error: use of
undeclared identifier 'strtoll_l'
long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/locale:779:35: error: use of
undeclared identifier 'strtoull_l'
unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET...
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/locale:808:12: error: use of
undeclared identifier 'strtof_l'
return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/locale:814:12: error: use of
undeclared identifier 'strtod_l'
return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/locale:820:12: error: use of
undeclared identifier 'strtold_l'; did you mean 'strtoll'?
return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:117:9: note:
'strtoll' declared here
using ::strtoll;
^
In file included from api.cpp:24:
In file included from ../inst/include/Rcpp.h:27:
In file included from ../inst/include/RcppCommon.h:51:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream:40:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/istream:163:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/ostream:140:
/Library/Developer/CommandLineTools/usr/include/c++/v1/locale:1094:9: error: use of
undeclared identifier 'sscanf_l'
if (__libcpp_sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__bsd_locale_defaults.h:35:61: note:
expanded from macro '__libcpp_sscanf_l'
#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__)
^
In file included from api.cpp:24:
In file included from ../inst/include/Rcpp.h:27:
In file included from ../inst/include/RcppCommon.h:51:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream:40:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/istream:163:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/ostream:140:
/Library/Developer/CommandLineTools/usr/include/c++/v1/locale:1199:18: error: use of
undeclared identifier 'isxdigit_l'; did you mean 'isxdigit'?
if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cctype:115:9: note:
'isxdigit' declared here
using ::isxdigit;
^
In file included from api.cpp:24:
In file included from ../inst/include/Rcpp.h:27:
In file included from ../inst/include/RcppCommon.h:51:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream:40:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/istream:163:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/ostream:140:
/Library/Developer/CommandLineTools/usr/include/c++/v1/locale:1199:18: error: too
many arguments to function call, expected 1, have 2; did you mean
'::std::isxdigit'?
if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
^~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/cctype:115:9: note:
'::std::isxdigit' declared here
using ::isxdigit;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [api.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp’
ERROR: dependency ‘Rcpp’ is not available for package ‘minqa’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/minqa’
ERROR: dependency ‘Rcpp’ is not available for package ‘RcppEigen’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppEigen’
ERROR: dependencies ‘minqa’, ‘nloptr’, ‘Rcpp’, ‘RcppEigen’ are not available for package ‘lme4’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/lme4’
The downloaded source packages are in
‘/private/var/folders/f7/v_vt_5bn07z9tljnh56n9crnrzdbg9/T/RtmpuouQQU/downloaded_packages’
Warning messages:
1: In install.packages("lme4") :
installation of package ‘nloptr’ had non-zero exit status
2: In install.packages("lme4") :
installation of package ‘Rcpp’ had non-zero exit status
3: In install.packages("lme4") :
installation of package ‘minqa’ had non-zero exit status
4: In install.packages("lme4") :
installation of package ‘RcppEigen’ had non-zero exit status
5: In install.packages("lme4") :
installation of package ‘lme4’ had non-zero exit status
Installation script
## remove binaries, etc
make distclean
## update
svn update
## get recommended tools
./tools/rsync-recommended
## other variables
PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/
JAVA_CPPFLAGS="-I/${JAVA_HOME}/include -I/${JAVA_HOME}/include/darwin"
JAVA_LD_LIBRARY_PATH="${JAVA_HOME}/jre/lib/server"
JAVA_LIBS="-L/${JAVA_HOME}/jre/lib/server -ljvm"
export LDFLAGS="-L/usr/local/opt/curl/lib -L/usr/local/opt/tcl-tk/lib"
export CPPFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -\
I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include"
export PKG_CONFIG_PATH="/usr/local/opt/tcl-tk/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:$PKG_CONFIG_PATH"
export CC=clang
export CXX=clang++
export FC=/usr/local/bin/gfortran
export OBJC=clang
export CFLAGS='-Wall -g -O3'
export CXXFLAGS='-Wall -g -O3'
export OBJCFLAGS='-Wall -g -O3'
export FFLAGS='-Wall -g -O3 -mtune=generic'
export LC_ALL='C'
./configure --enable-R-framework=/Library/Frameworks/ \
--with-blas="-framework Accelerate" --with-lapack \
--x-includes=/opt/X11/include --x-libraries=/opt/X11/lib \
--with-internal-tzcode --with-cairo=yes
make
make install
R session
> sessionInfo()
R Under development (unstable) (2020-09-29 r79274)
Platform: x86_64-apple-darwin18.7.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0 tcltk_4.1.0
Hombrew Version
bash-3.2$ brew --version
Homebrew 2.5.2
Homebrew/homebrew-core (git revision f5bfb; last commit 2020-09-25)
Homebrew/homebrew-cask (git revision a5844b; last commit 2020-09-25)

How to get the emgucv compiled on my Ubuntu 18.04? It is said to support Ubuntu

First I am not very familiar with C++ compile process, but I have to compile the emgucv repository on Ubuntu 18.04. I follow the instruction and try to figure out things by searching through Stack Exchange.
I got every dependencies setup, then the only file I need to execute is this one.
Although it is written for 16.04, seems to work for 18.04, but the compilation throws an error. It says _MAX_DRIVE, _MAX_DIR, _MAX_PATH, DWORD, errno_t, etc. are not declared. As suggested by the comment, they are Windows-specific. The error occurs in this file. And the module that contains this file is this.
My question is how to get this compiled on Ubuntu 18.04? I am very confused, since Emgucv says they support Linux (instruction at the end), and I believe others could have successfully compiled it on their Linux. I attempted to replace those constants _MAX_DRIVE, _MAX_DIR, _MAX_PATH by just numbers, the DWORD by unsigned long, and errno_t by int, then it says now GetModuleFileName, _splitpath_s are not declared. I don't know how to do. Is there anyway for this to work for Ubuntu?
[ 74%] Building CXX object Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp: In member function ‘void tesseract::CCUtil::main_setup(const char*, const char*)’:
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:77:16: error: ‘_MAX_DRIVE’ was not declared in this scope
char drive[_MAX_DRIVE];
^~~~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:78:14: error: ‘_MAX_DIR’ was not declared in this scope
char dir[_MAX_DIR];
^~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:79:15: error: ‘_MAX_PATH’ was not declared in this scope
char path[_MAX_PATH];
^~~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:83:5: error: ‘DWORD’ was not declared in this scope
DWORD length = GetModuleFileName(nullptr, path, sizeof(path));
^~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:85:9: error: ‘length’ was not declared in this scope
if (length > 0 && length < sizeof(path)) {
^~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:85:39: error: ‘path’ was not declared in this scope
if (length > 0 && length < sizeof(path)) {
^~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:86:7: error: ‘errno_t’ was not declared in this scope
errno_t result = _splitpath_s(path, drive, sizeof(drive),
^~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:88:11: error: ‘result’ was not declared in this scope
if (result == ERANGE) {
^~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:92:17: error: ‘drive’ was not declared in this scope
datadir = drive;
^~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:93:18: error: ‘dir’ was not declared in this scope
datadir += dir;
^~~
Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/build.make:302: recipe for target 'Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o' failed
make[2]: *** [Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o] Error 1
CMakeFiles/Makefile2:5929: recipe for target 'Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/all' failed
make[1]: *** [Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
Emgu CV compile manual for Ubuntu
The commands are summarized below
git clone https://github.com/emgucv/emgucv emgucv
cd emgucv
git submodule update --init --recursive
cd platforms/ubuntu/16.04
./apt_install_dependency.sh
./cmake_configure.sh

Can I install raspicam c++ libraries on OS X?

I'm developing an OpenCV project that will run on a raspberry pi. So far I have been developing on a Mac in Xcode and all is going well. I recently realized that in order to tap into the raspberry pi camera I will need to use the raspicam library.
My question is, can I install raspicam libraries on OS X or are they raspberry pi hardware specific?
I would like to be able to develop, compile, and build on my Mac as well as compile and build on the raspberry pi. I am trying to avoid doing my development on the Pi.
If that's not possible do you have any recommendations for how I should manage the development setup for this project?
There is only a small section of my code that requires the raspicam libraries so I am not opposed to having a flag that executes the raspicam code if running on the Pi, otherwise executes the currently working OpenCV code if running on the Mac.
So far I have downloaded the raspicam source and I have done:
cd raspicam-0.1.3
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV" ..
And here is the output:
-- Adding cv library
--
-- -------------------------------------------------------------------------------
-- General configuration for raspicam 0.1.2
-- -------------------------------------------------------------------------------
--
Built as dynamic libs?:ON
Compiler:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- C++ flags (Release): -std=c++0x -Wl,--no-as-needed -lpthread
-- C++ flags (Debug): -std=c++0x -Wl,--no-as-needed -lpthread
-- CMAKE_CXX_FLAGS: -std=c++0x -Wl,--no-as-needed
-- CMAKE_BINARY_DIR: /Users/andres/Downloads/raspicam-0.1.3/build
--
-- CMAKE_SYSTEM_PROCESSOR = x86_64
-- BUILD_SHARED_LIBS = ON
-- BUILD_UTILS = ON
-- CMAKE_INSTALL_PREFIX = /usr/local
-- CMAKE_BUILD_TYPE = Release
-- CMAKE_MODULE_PATH = /usr/local/lib/cmake/;/usr/lib/cmake
--
-- CREATE OPENCV MODULE=1
-- CMAKE_INSTALL_PREFIX=/usr/local
-- REQUIRED_LIBRARIES=
--
--
-- Change a value with: cmake -D<Variable>=<Value>
--
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
raspicam
raspicam_cv
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /Users/andres/Downloads/raspicam-0.1.3/build
Then
make
Output:
Scanning dependencies of target raspicam_cv
[ 5%] Building CXX object src/CMakeFiles/raspicam_cv.dir/raspicam_cv.cpp.o
clang: warning: -Wl,--no-as-needed: 'linker' input unused
clang: warning: -lpthread: 'linker' input unused
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:297:22: error:
use of undeclared identifier 'CLOCK_REALTIME'
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
^
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:307:13: error:
use of undeclared identifier 'sem_timedwait'
ret = sem_timedwait( sem, &ts );
^
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:327:13: warning:
'sem_init' is deprecated [-Wdeprecated-declarations]
int rc = sem_init(sem, 0, initial_count);
^
/usr/include/sys/semaphore.h:55:5: note: 'sem_init' has been explicitly marked
deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:335:13: warning:
'sem_destroy' is deprecated [-Wdeprecated-declarations]
int rc = sem_destroy(sem);
^
/usr/include/sys/semaphore.h:53:5: note: 'sem_destroy' has been explicitly
marked deprecated here
int sem_destroy(sem_t *) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:520:13: warning:
'sem_init' is deprecated [-Wdeprecated-declarations]
int rc = sem_init(&event->sem, 0, 0);
^
/usr/include/sys/semaphore.h:55:5: note: 'sem_init' has been explicitly marked
deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:525:7: warning:
'sem_destroy' is deprecated [-Wdeprecated-declarations]
sem_destroy(&event->sem);
^
/usr/include/sys/semaphore.h:53:5: note: 'sem_destroy' has been explicitly
marked deprecated here
int sem_destroy(sem_t *) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:541:8: warning:
'sem_getvalue' is deprecated [-Wdeprecated-declarations]
if (sem_getvalue(&event->sem, &value) != 0)
^
/usr/include/sys/semaphore.h:54:5: note: 'sem_getvalue' has been explicitly
marked deprecated here
int sem_getvalue(sem_t * __restrict, int * __restrict) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:582:13: warning:
'sem_destroy' is deprecated [-Wdeprecated-declarations]
int rc = sem_destroy(&event->sem);
^
/usr/include/sys/semaphore.h:53:5: note: 'sem_destroy' has been explicitly
marked deprecated here
int sem_destroy(sem_t *) __deprecated;
^
6 warnings and 2 errors generated.
make[2]: *** [src/CMakeFiles/raspicam_cv.dir/raspicam_cv.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/raspicam_cv.dir/all] Error 2
make: *** [all] Error 2
The solution I came up with was to use:
#ifdef __ARM__
include <raspicam/raspicam.h>
#endif
and in the main
#ifdef __ARM__
// pi specific camera initialization code
#elif __APPLE__
// osx specific camera initialization code
#endif
These preprocessors will be evaluated before the code is compiled. If the source is being compiled on the pi (ARM architecture) the __ARM__ sections will be compiled, otherwise if the source code is being compiled on osx the __APPLE__ sections will be compiled.

Error with google-sparsehash in mac os x mavericks 10.9.3

I'm compiling a C++ project that depends on google-sparsehash.
So I did install sparse through brew install google-sparsehash --cc=gcc-4.2 command.
But, when I finally compile my project I got fatal error: 'tr1/functional' file not found. I'd like to solve this problem, could you help me?
The output of the compiler is showed bellow:
c++ -- cb/allBalances.cpp
c++ -- cb/allAddresses.cpp
c++ -- callback.cpp
c++ -- cb/closure.cpp
c++ -- cb/dumpTX.cpp
c++ -- parser.cpp
c++ -- cb/pristine.cpp
c++ -- cb/rewards.cpp
clang: clang: clangclang: : clangclang: : clangclang: : warning: warning: warning: warning: warning: warning: warning: warning: argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'
In file included from cb/rewards.cpp:4:
In file included from ./util.h:103:
In file included from /usr/local/include/google/dense_hash_map:34:
/usr/local/include/sparsehash/dense_hash_map:106:10: fatal error: 'tr1/functional' file not found
In file included from cb/pristine.cpp:4:
In file included from ./util.h:103:
In file included from /usr/local/include/google/dense_hash_map:34:
/usr/local/include/sparsehash/dense_hash_map:106:10: fatal error: 'tr1/functional' file not found
In file included from cb/closure.cpp:4:
In file included from ./util.h:103:
In file included from /usr/local/include/google/dense_hash_map:34:
/usr/local/include/sparsehash/dense_hash_map:106:10: fatal error: 'tr1/functional' file not found
#include HASH_FUN_H // for hash<>#include HASH_FUN_H // for hash<>
^
When I type c++ -v I get:
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
Thank you.

How can I understand these dreadful errors when building gcc-4.8.2?

I am trying to install the gcc-4.8.2 compiler on a remote Debian 7 system, to which I have no root privileges, but only a ssh access. I figured out that the simplest way would be to compile the compiler from source.
I am following this short installation manual from the GCC webpage.
Basically I did the most simple installation, which is summarized at the bottom of the page:
tar xzf gcc-4.8.2.tar.gz
cd gcc-4.8.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.2/configure --prefix=$HOME/gcc-4.8.2 --enable-languages=c++
make
with the small exception that I did not run the ./contrib/download_prerequisites script on the remote machine because of firewall restrictions. Instead I ran it on my local machine, then compressed the entire folder back into gcc-4.8.2.tar.gz and scp'd it to the remote machine. There I re-created the symbolic links to the prerequisite libraries (gmp,...) and ran make. After several seconds I receive incredible errors:
In file included from ./tm.h:19:0,
from ../../gcc-4.8.2/gcc/c/c-lang.c:24:
./options.h:4078:2: error: #error too many masks for ix86_isa_flags
In file included from ../../gcc-4.8.2/gcc/tree.h:26:0,
from ../../gcc-4.8.2/gcc/c/c-lang.c:25:
../../gcc-4.8.2/gcc/statistics.h:25:2: error: #error GATHER_STATISTICS must be defined
In file included from ../../gcc-4.8.2/gcc/system.h:268:0,
from ../../gcc-4.8.2/gcc/c/c-lang.c:22:
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
../../gcc-4.8.2/gcc/hwint.h:16:39: error: division by zero in #if
In file included from ../../gcc-4.8.2/gcc/tree.h:29:0,
from ../../gcc-4.8.2/gcc/c/c-lang.c:25:
../../gcc-4.8.2/gcc/real.h:103:9: error: #error "REAL_WIDTH > 6 not supported"
In file included from ../../gcc-4.8.2/gcc/c-family/c-common.h:24:0,
from ../../gcc-4.8.2/gcc/c/c-tree.h:23,
from ../../gcc-4.8.2/gcc/c/c-lang.c:26:
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:265:3: error: #error "Cannot find a least-32-bit signed integer type"
In file included from ../../gcc-4.8.2/gcc/c/c-lang.c:22:0:
../../gcc-4.8.2/gcc/system.h:500:34: error: declaration of C function ‘const char* strsignal(int)’ conflicts with
In file included from /usr/include/c++/4.7/cstring:44:0,
from ../../gcc-4.8.2/gcc/system.h:205,
from ../../gcc-4.8.2/gcc/c/c-lang.c:22:
/usr/include/string.h:566:14: error: previous declaration ‘char* strsignal(int)’ here
In file included from ../../gcc-4.8.2/gcc/system.h:645:0,
from ../../gcc-4.8.2/gcc/c/c-lang.c:22:
../../gcc-4.8.2/gcc/../include/libiberty.h:110:36: error: new declaration ‘char* basename(const char*)’
In file included from /usr/include/c++/4.7/cstring:44:0,
from ../../gcc-4.8.2/gcc/system.h:205,
from ../../gcc-4.8.2/gcc/c/c-lang.c:22:
/usr/include/string.h:603:28: error: ambiguates old declaration ‘const char* basename(const char*)’
In file included from ../../gcc-4.8.2/gcc/tree.h:27:0,
from ../../gcc-4.8.2/gcc/c/c-lang.c:25:
../../gcc-4.8.2/gcc/vec.h: In static member function ‘static void va_heap::reserve(vec<T, va_heap, vl_embed>*&, unsigned int, bool)’:
../../gcc-4.8.2/gcc/vec.h:295:7: error: ‘GATHER_STATISTICS’ was not declared in this scope
../../gcc-4.8.2/gcc/vec.h:303:7: error: ‘GATHER_STATISTICS’ was not declared in this scope
../../gcc-4.8.2/gcc/vec.h: In static member function ‘static void va_heap::release(vec<T, va_heap, vl_embed>*&)’:
../../gcc-4.8.2/gcc/vec.h:317:7: error: ‘GATHER_STATISTICS’ was not declared in this scope
In file included from ../../gcc-4.8.2/gcc/tree.h:29:0,
from ../../gcc-4.8.2/gcc/c/c-lang.c:25:
../../gcc-4.8.2/gcc/real.h: At global scope:
../../gcc-4.8.2/gcc/real.h:51:21: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:51:21: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:76:31: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:76:31: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:76:31: error: ‘SIZEOF_LONG’ was not declared in this scope
../../gcc-4.8.2/gcc/real.h:76:31: error: ‘SIZEOF_LONG’ was not declared in this scope
In file included from ../../gcc-4.8.2/gcc/c-family/c-common.h:24:0,
from ../../gcc-4.8.2/gcc/c/c-tree.h:23,
from ../../gcc-4.8.2/gcc/c/c-lang.c:26:
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:267:35: error: expected initializer before ‘cppchar_t’
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:268:9: error: ‘CPPCHAR_SIGNED_T’ does not name a type
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:777:8: error: ‘cppchar_t’ does not name a type
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:788:8: error: ‘cppchar_t’ does not name a type
../../gcc-4.8.2/gcc/../libcpp/include/cpplib.h:966:8: error: ‘cppchar_t’ does not name a type
make[3]: *** [c/c-lang.o] Error 1
make[3]: Leaving directory `/home/mdrozdik/gccbuild/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/mdrozdik/gccbuild'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/mdrozdik/gccbuild'
make: *** [all] Error 2
I am compiling with gcc 4.7.2-5 on Debian.
On the local machine there is Ubuntu 13.10 with gcc 4.7.3 and the build seems fine so far (still running).
Please, what could be the cause of these errors?
EDIT:
I checked the /home/mdrozdik/gccbuild/libcpp/config.log file. It is very longm but in two places there are these errors:
configure:3086: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3097: $? = 4
configure:3086: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:3097: $? = 4
But the log continues for several pages nevertheless.
I had a similar problem (gcc 4.8.3) and this solved it: g++ 4.7.1 compilation error : conflicting types for ‘strsignal’
The solution was to unset a bunch of C compiler flags (CPATH, etc.)
https://stackoverflow.com/users/1224886/tsbertalan reported this worked for him (and it's what I used):
unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE