How do I resolve error with clang when install R package? - c++

I was trying to use devtool to install a R package,
devtools::install_github("haimbar/SEMMS")
But it says there are some problem with
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include' -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/RcppArmadilloForward.h:48:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/armadillo:23:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/armadillo_bits/compiler_check.hpp:72:4: error: "*** C++11 compiler required; enable C++11 mode in your compiler, or use an earlier version of Armadillo"
#error "*** C++11 compiler required; enable C++11 mode in your compiler, or use an earlier version of Armadillo"
^
In file included from RcppExports.cpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/RcppArmadilloForward.h:48:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/armadillo:87:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include/armadillo_bits/arma_forward.hpp:152:12: error: unknown type name 'constexpr'
static constexpr bool is_row = false;
^`
I think it is about the clang version but don't know how to fix it.

Related

OpenCV 4.x+ requires enabled C++11 support on MacOS

I've have my motion detection program written in C++, running correctly in Linux.
Just copy and test in MacOS, but got the error "OpenCV 4.x+ requires enabled C++11":
In file included from video_process.cpp:1:
In file included from ./video_process.h:17:
In file included from ./yolov4.h:1:
In file included from /usr/local/include/opencv2/imgproc.hpp:46:
In file included from /usr/local/include/opencv2/core.hpp:52:
/usr/local/include/opencv2/core/cvdef.h:732:4: error: "OpenCV 4.x+ requires enabled C++11 support"
error "OpenCV 4.x+ requires enabled C++11 support"
^
In file included from video_process.cpp:1:
In file included from ./video_process.h:17:
In file included from ./yolov4.h:1:
In file included from /usr/local/include/opencv2/imgproc.hpp:46:
In file included from /usr/local/include/opencv2/core.hpp:54:
In file included from /usr/local/include/opencv2/core/base.hpp:58:
In file included from /usr/local/include/opencv2/core/cvstd.hpp:81:
I have -std=c++11 in my Makefile, and the code is working correctly in Linux.
What could cause this problem on MacOS?..
Makefile:
CFLAGS = -w -std=c++11 -I/usr/local/lib -I/usr/include/mysql `pkg-config --cflags opencv4` -pthread
LIBS = -L/usr/local/lib/mysql `pkg-config --libs opencv4` -lmysqlclient
OBJS = video_process.o motion_background_diff.o yolov4.o preprocess.o
TARGET = motion_detection
$(TARGET) : $(OBJS)
g++ $(CFLAGS) -o $# $^ $(LIBS)

MacOS Big Sur x86_64 complier error during R devtool install

I am trying to install an R package with the following command:
devtools::install_github('ococrook/bandle)
However, I keep running into compiler issues. When I run the command I get many, many errors. For example this error related to BH:
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/BH/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -Wall -pedantic -fdiagnostics-color=always -c Bessel2ndKind.cpp -o Bessel2ndKind.o
In file included from Bessel2ndKind.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include/RcppArmadillo.h:34:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:59:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/exceptions_impl.h:38:
In file included from /usr/local/include/execinfo.h:28:
/usr/local/include/os/base.h:274:37: warning: type nullability specifier '_Nullable' is a Clang extension [-Wnullability-extension]
typedef void (*os_function_t)(void *_Nullable);
^
Bessel2ndKind.cpp:621:55: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
nk, tau, D = D, j + 1, nu).t();
~ ^ ~
Bessel2ndKind.cpp:774:49: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
nk, tau, D = D, j + 1).t();
~ ^ ~
In file included from Bessel2ndKind.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/BH/include/boost/math/special_functions/bessel.hpp:24:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/BH/include/boost/math/special_functions/detail/bessel_ik.hpp:97:18: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
BOOST_ASSERT(abs(x) <= 2);
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/BH/include/boost/math/special_functions/detail/bessel_ik.hpp:366:9: note: in instantiation of function template specialization 'boost::math::detail::temme_ik<long double, boost::math::policies::policy<detail::forwarding_arg1, detail::forwarding_arg2>>' requested here
temme_ik(u, x, &Ku, &Ku1, pol); // Temme series
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/BH/include/boost/math/special_functions/bessel.hpp:246:4: note: in instantiation of function template specialization 'boost::math::detail::bessel_ik<long double, boost::math::policies::policy<detail::forwarding_arg1, detail::forwarding_arg2>>' requested here
bessel_ik(v, x, &I, &K, need_k, pol);
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/BH/include/boost/math/special_functions/bessel.hpp:258:11: note: in instantiation of function template specialization 'boost::math::detail::cyl_bessel_k_imp<long double, boost::math::policies::policy<detail::forwarding_arg1, detail::forwarding_arg2>>' requested here
return cyl_bessel_k_imp(v, x, bessel_no_int_tag(), pol);
^
Or this error related to RcppArmadillo:
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/BH/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -Wall -pedantic -fdiagnostics-color=always -c leapfrogGPcpp.cpp -o leapfrogGPcpp.o
In file included from leapfrogGPcpp.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include/RcppArmadillo.h:34:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:59:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/exceptions_impl.h:38:
In file included from /usr/local/include/execinfo.h:28:
/usr/local/include/os/base.h:274:37: warning: type nullability specifier '_Nullable' is a Clang extension [-Wnullability-extension]
typedef void (*os_function_t)(void *_Nullable);
^
In file included from leapfrogGPcpp.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include/RcppArmadillo.h:31:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include/RcppArmadilloForward.h:49:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include/armadillo:646:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include/armadillo_bits/op_inv_meat.hpp:200:28: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
const T abs_det_val = std::abs(det_val);
So far I have tried this, and this, and this, and this. However, so far, none of these solutions have worked and I am running out of ideas on how to solve this.
Any help would be greatly appreciated,
Thanks!
Try following the instructions here and change the default timeout to ensure the relatively large "pRolocdata" package is downloaded completely, i.e.
options(timeout = 600)
devtools::install_github('ococrook/bandle')
Using this approach, Bandle installed with a bunch of warnings but without error on my system.
sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.6
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] compiler_4.1.1 tools_4.1.1
My ~/.R/Makevars file:
LOC = /usr/local/gfortran
CC=$(LOC)/bin/gcc -fopenmp
CXX=$(LOC)/bin/g++ -fopenmp
CXX11 = $(LOC)/bin/g++ -fopenmp
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib
CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX1X=/usr/local/gfortran/bin/g++
CXX98=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
CXX14=/usr/local/gfortran/bin/g++
CXX17=/usr/local/gfortran/bin/g++

Make fails on Mac

I'm trying to make my project using Makefile. The Makefile works correctly for other Mac's but bring error in my case.
The output is as follows:
CC kernel.cpp
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:313:9: error:
no member named 'signbit' in the global namespace
using ::signbit;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:314:9: error:
no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:315:9: error:
no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/math.h:757:12: note:
'finite' declared here
extern int finite(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __M...
^
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:316:9: error:
no member named 'isinf' in the global namespace
using ::isinf;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:317:9: error:
no member named 'isnan' in the global namespace
using ::isnan;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:318:9: error:
no member named 'isnormal' in the global namespace
using ::isnormal;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:319:7: error:
no member named 'isgreater' in the global namespace; did you mean
'::std::greater'?
using ::isgreater;
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:718:29: note:
'::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
^
In file included from kernel.cpp:13:
In file included from ./kernel.hpp:22:
In file included from /usr/local/include/Poco/JSON/Object.h:24:
In file included from /usr/local/include/Poco/JSON/Array.h:25:
In file included from /usr/local/include/Poco/Dynamic/Var.h:26:
In file included from /usr/local/include/Poco/Dynamic/VarHolder.h:24:
In file included from /usr/local/include/Poco/NumberFormatter.h:24:
In file included from /usr/local/include/Poco/NumericString.h:25:
In file included from /usr/local/include/Poco/FPEnvironment.h:35:
In file included from /usr/local/include/Poco/FPEnvironment_C99.h:25:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:320:7: error:
no member named 'isgreaterequal' in the global namespace; did you mean
'::std::greater_equal'?
using ::isgreaterequal;
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:747:29: note:
'::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
^
The makefile has been tested on Linux platforms, and it's works correctly.
Any recommendations, whats wrong in my Mac c++ configs ?
I'm using MacOS High Sierra(10.13), and Xcode v9.0.1
Edited
This is compiling command:
gcc -pipe -x c++ -std=c++11 -fPIC -pedantic -W -Wall -Wwrite-strings -Wcast-align -Wcast-qual -Wpointer-arith -Wshadow -Wendif-labels -Wundef -Wfloat-equal -Werror -Wconversion -DPROJECT_VERSION="0.0.1" -DUSE_SDK="no" -g -g3 -ggdb3 -D__i386__=1 -D__ppc64__=0 -Wno-sign-conversion -Wno-conversion -Wno-float-equal -Wno-unused-parameter -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/version -I/git/p2p/inc -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/version src/kernel.cpp -o /git/p2p/obj/kernel.o
Instead of running gcc -x c++ I recommend you run g++ or, better on MacOS, clang++.
Also, your compile line appears to be missing the -c option which would tell the compiler to generate an object file; without that it will try to link your file and create an executable.
Also I find it very strange that you have added -D__i386__ and -D__ppc64__ to your compile line: those are typically system macros that are defined by your operating system, not provided on the command line of the compiler.
Another potential problem is why you are explicitly adding system header file directories to your compile line with -I. The compiler will add those itself, and using the proper configuration. System headers often require extra care to include in the correct order etc.
If you change to the proper directory and run this from your shell prompt:
clang++ -pipe -std=c++11 -fPIC -pedantic -W -Wall -Wwrite-strings \
-Wcast-align -Wcast-qual -Wpointer-arith -Wshadow -Wendif-labels \
-Wundef -Wfloat-equal -Werror -Wconversion -DPROJECT_VERSION="0.0.1" \
-DUSE_SDK="no" -g -g3 -ggdb3 -Wno-sign-conversion -Wno-conversion \
-Wno-float-equal -Wno-unused-parameter -I/usr/local/include \
-I/usr/local/opt/openssl/include -I/git/p2p/inc \
-c -o /git/p2p/obj/kernel.o src/kernel.cpp
does it compile properly?
Upgrade your packages :
$ brew update
$ brew upgrade
With XCode updated, it could be fixed.

Why Python.h of python 3.2 must be included as first together with Qt4

I have a qt application and I want to implement python interpreter into it so that I can extend it with python scripts. While this works fine for regular C++ application, including Python.h even for most simple, empty Qt4 project always result in:
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I/usr/include/python3.2mu -I. -o main.o main.cpp
In file included from /usr/include/python3.2mu/Python.h:8:0,
from main.cpp:16:
/usr/include/python3.2mu/pyconfig.h:1182:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]
/usr/include/features.h:164:0: note: this is the location of the previous definition
/usr/include/python3.2mu/pyconfig.h:1204:0: warning: "_XOPEN_SOURCE" redefined [enabled by default]
/usr/include/features.h:166:0: note: this is the location of the previous definition
In file included from /usr/include/python3.2mu/Python.h:67:0,
from main.cpp:16:
/usr/include/python3.2mu/object.h:402:23: error: expected unqualified-id before ‘;’ token
make: *** [main.o] Error 1
I only implemented this in my .pro file:
INCLUDEPATH += "/usr/include/python3.2"
now anytime when I do
#include <Python.h>
in any .h file it makes it unbuildable. Why is that?
Note: This all works perfectly with python 2.7, just python 3x doesn't work
EDIT: I figured out, that when I include Python.h as first file, before Qt includes, it works, is this a bug in python? Are they missing some safe guards?
The documentation of the Python C-API states:
Note Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included.
It is very likely that some of the Qt headers include standard headers (as evident from the error you get, it does include /usr/include/features.h, or example), therefore #include <Python.h> should be placed before the Qt headers. In fact, it should generally be placed before any other include-statement.
Note that this is the case with Python 2.7, too. If a different include order works for you with Python 2.7, then you are simply lucky.

libcurl compile error in 64bit Centos when passing -m32 parameter

Please help!
I'm having the problem below when compiling my code. Do you have any fix on the libcurl issue esp the missing file? I am using Centos 64bit. m32 option is needed because some shared object is 32bit.
g++ -c -g -m32 -o c-wrapper.o c-wrapper.cpp -D__C_FILES "-I../include" -DLINUX
gcc -c -g -m32 -o Example_c.o `mysql_config --libs` -lcurl Example_c.c -D__C_FILES "- I../include" -DLINUX
In file included from /usr/include/curl/curl.h:43,
from Example_c.c:2:
/usr/include/curl/curlbuild.h:4:26: error: curlbuild-32.h: No such file or directory
In file included from /usr/include/curl/curl.h:44,
from Example_c.c:2:
/usr/include/curl/curlrules.h:80:4: error: #error "CURL_SIZEOF_LONG definition is missing!"
In file included from /usr/include/curl/curl.h:44,
...
Thanks!
Try:
sudo yum install libcurl-devel.i686