Unable to build AllJoyn JS Bindings & Compiler too old to build AllJoyn when building for Android - alljoyn

This is how I set up AllJoyn:
cd /opt
sudo mkdir alljoyn
sudo chown -R danny:danny alljoyn
cd alljoyn
repo init -u https://git.allseenalliance.org/gerrit/devtools/manifest.git
repo sync
repo start master --all
Now, I would like to build AllJoyn js bindings, but getting Exceptions (c, cpp and java worked out of the box):
/opt/alljoyn/core/alljoyn$ scons BINDINGS=js GECKO_BASE=/opt/xulrunner-sdk
scons: Reading SConscript files ...
Checking c++ compiler support for -std=c++11 flag... (cached) yes
Using OpenSSL crypto
Building bindings: js
Building services:
GTEST_DIR not specified skipping common unit test build
GTEST_DIR not specified skipping About Service unit test build
GTEST_DIR not specified skipping alljoyn_core unit test build
SQLITE_DIR not specified: skipping Security Manager sample program build
scons: done reading SConscript files.
scons: Building targets ...
[CXX-SH] alljoyn_js/jni/ProxyBusObjectHost.cc
alljoyn_js/jni/ProxyBusObjectHost.cc: In constructor 'ReplyReceiver::ReplyReceiver(Plugin&, BusAttachment&, ProxyBusObject&, qcc::String&, qcc::String&, CallbackNative*, const NPVariant*, uint32_t)':
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: error: no matching function for call to 'qcc::ManagedObj<ReplyReceiver::_Env>::ManagedObj(ReplyReceiver*, Plugin&, BusAttachment&, ProxyBusObject&, qcc::String&, qcc::String&, CallbackNative*&, const NPVariant*&, uint32_t&)'
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:488:5: note: candidate: qcc::ManagedObj<T>::ManagedObj(qcc::ManagedObj<T>::ManagedCtx*, T*) [with T = ReplyReceiver::_Env]
ManagedObj<T>(ManagedCtx* context, T* object) : context(context), object(object)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:488:5: note: candidate expects 2 arguments, 9 provided
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:348:146: note: candidate: template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> qcc::ManagedObj<T>::ManagedObj(A1&, A2&, A3&, A4&, A5&, A6&, A7&, A8&, A9&, A10&)
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10> ManagedObj<T>(A1 & arg1, A2 & arg2, A3 & arg3, A4 & arg4, A5 & arg5, A6 & arg6, A7 & arg7, A8 & arg8, A9 & arg9, A10 & arg10)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:348:146: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 10 arguments, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:324:132: note: candidate: qcc::ManagedObj<T>::ManagedObj(A1&, A2&, A3&, A4&, A5&, A6&, A7&, A8&, A9&) [with A1 = ReplyReceiver*; A2 = qcc::ManagedObj<_Plugin>; A3 = qcc::ManagedObj<ajn::BusAttachment>; A4 = qcc::ManagedObj<ajn::ProxyBusObject>; A5 = qcc::String; A6 = qcc::String; A7 = CallbackNative*; A8 = const _NPVariant*; A9 = unsigned int; T = ReplyReceiver::_Env] <near match>
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9> ManagedObj<T>(A1 & arg1, A2 & arg2, A3 & arg3, A4 & arg4, A5 & arg5, A6 & arg6, A7 & arg7, A8 & arg8, A9 & arg9)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:324:132: note: conversion of argument 1 would be ill-formed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: error: invalid initialization of non-const reference of type 'ReplyReceiver*&' from an rvalue of type 'ReplyReceiver*'
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:301:119: note: candidate: template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> qcc::ManagedObj<T>::ManagedObj(A1&, A2&, A3&, A4&, A5&, A6&, A7&, A8&)
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8> ManagedObj<T>(A1 & arg1, A2 & arg2, A3 & arg3, A4 & arg4, A5 & arg5, A6 & arg6, A7 & arg7, A8 & arg8)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:301:119: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 8 arguments, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:279:106: note: candidate: template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> qcc::ManagedObj<T>::ManagedObj(A1&, A2&, A3&, A4&, A5&, A6&, A7&)
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7> ManagedObj<T>(A1 & arg1, A2 & arg2, A3 & arg3, A4 & arg4, A5 & arg5, A6 & arg6, A7 & arg7)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:279:106: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 7 arguments, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:258:93: note: candidate: template<class A1, class A2, class A3, class A4, class A5, class A6> qcc::ManagedObj<T>::ManagedObj(A1&, A2&, A3&, A4&, A5&, A6&)
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6> ManagedObj<T>(A1 & arg1, A2 & arg2, A3 & arg3, A4 & arg4, A5 & arg5, A6 & arg6)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:258:93: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 6 arguments, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:238:80: note: candidate: template<class A1, class A2, class A3, class A4, class A5> qcc::ManagedObj<T>::ManagedObj(A1&, A2&, A3&, A4&, A5&)
template <typename A1, typename A2, typename A3, typename A4, typename A5> ManagedObj<T>(A1 & arg1, A2 & arg2, A3 & arg3, A4 & arg4, A5 & arg5)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:238:80: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 5 arguments, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:222:67: note: candidate: template<class A1, class A2, class A3, class A4> qcc::ManagedObj<T>::ManagedObj(A1&, A2&, A3&, A4&)
template <typename A1, typename A2, typename A3, typename A4> ManagedObj<T>(A1 & arg1, A2 & arg2, A3 & arg3, A4 & arg4)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:222:67: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 4 arguments, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:204:54: note: candidate: template<class A1, class A2, class A3> qcc::ManagedObj<T>::ManagedObj(A1&, A2&, A3&)
template <typename A1, typename A2, typename A3> ManagedObj<T>(A1 & arg1, A2 & arg2, A3 & arg3)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:204:54: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 3 arguments, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:190:41: note: candidate: template<class A1, class A2> qcc::ManagedObj<T>::ManagedObj(A1&, A2&)
template <typename A1, typename A2> ManagedObj<T>(A1 & arg1, A2 & arg2)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:190:41: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 2 arguments, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:174:28: note: candidate: template<class A1> qcc::ManagedObj<T>::ManagedObj(A1&)
template <typename A1> ManagedObj<T>(A1 & arg1)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:174:28: note: template argument deduction/substitution failed:
alljoyn_js/jni/ProxyBusObjectHost.cc:122:119: note: candidate expects 1 argument, 9 provided
env(this, plugin, busAttachment, proxyBusObject, interfaceName, methodName, callbackNative, npargs, npargCount) { }
^
In file included from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/Message.h:30:0,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/AuthListener.h:32,
from build/linux/x86_64/debug/dist/cpp/inc/alljoyn/BusAttachment.h:34,
from alljoyn_js/jni/BusAttachment.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.h:19,
from alljoyn_js/jni/ProxyBusObjectHost.cc:16:
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:133:5: note: candidate: qcc::ManagedObj<T>::ManagedObj() [with T = ReplyReceiver::_Env]
ManagedObj<T>()
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:133:5: note: candidate expects 0 arguments, 9 provided
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:113:5: note: candidate: qcc::ManagedObj<T>::ManagedObj(const qcc::ManagedObj<T>&, bool) [with T = ReplyReceiver::_Env]
ManagedObj<T>(const ManagedObj<T>&other, bool isDeep)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:113:5: note: candidate expects 2 arguments, 9 provided
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:91:5: note: candidate: qcc::ManagedObj<T>::ManagedObj(qcc::ManagedObj<T>&) [with T = ReplyReceiver::_Env]
ManagedObj<T>(ManagedObj<T>&copyMe)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:91:5: note: candidate expects 1 argument, 9 provided
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:83:5: note: candidate: qcc::ManagedObj<T>::ManagedObj(const qcc::ManagedObj<T>&) [with T = ReplyReceiver::_Env]
ManagedObj<T>(const ManagedObj<T>&copyMe)
^
build/linux/x86_64/debug/dist/cpp/inc/qcc/ManagedObj.h:83:5: note: candidate expects 1 argument, 9 provided
scons: *** [build/linux/x86_64/debug/obj/alljoyn_js/jni/ProxyBusObjectHost.os] Error 1
scons: building terminated because of errors.
And when trying to build AllJoyn on Linux for my Android device it complains the compiler is too old:
/opt/alljoyn/core/alljoyn$ scons OS=android CRYPTO=builtin ANDROID_NDK=/opt/android-ndk-r13
scons: Reading SConscript files ...
Checking c++ compiler support for -std=c++11 flag... no
Checking c++ compiler support for -std=c++0x flag... no
*** Compiler too old to build AllJoyn. Aborting.
I'm using the following compiler versions:
$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I'm really confused as from above the c++ compiler should have support for -std=c++11 flag.
Notice: I've downloaded NDK r13 and had to create /opt/android-ndk-r13/RELEASE.TXT which contains r13a in order to pass the version check.
List of /opt:
$ ls /opt
alljoyn android-ndk-r13 android-sdk-linux android-studio xulrunner-sdk
And btw: Setting up and building AllJoyn is a mess. Docs are outdated and contradictory.

--Answer not related to the main topic-- I agree the documents are sometimes very confusing, and now since the merger is on the way there will be more cases of Documents being even more less updated.

Related

R use stats::optimize in Rcpp, simple example fails to compile

I want to use the R stats::optimize function in Rcpp because I haven't been able to find an Rcpp equivalent. The code below is my attempt at a simple example based on the Example in the optimize help, but fails.
Here's the R function and results
f <- function (x) (x - .33)^2
xmin <- optimize(f, c(0, 1), tol = 0.0001)
xmin
This returns
$minimum
[1] 0.333
$objective
[1] 0
Here's the Rcpp code that fails when sourcing it.
#include <Rcpp.h>
const double tolerance = 1e-0;
// [[Rcpp::export]]
Rcpp::NumericVector f(Rcpp::NumericVector x) {
return pow(x-0.33, 2);
}
Rcpp::List fTg_opt(const double optmin, const double optmax) {
Rcpp::Environment base("package:stats");
Rcpp::Function optimize_r = base["optimize"];
Rcpp::NumericVector interval = {optmin,optmax};
return optimize_r(f, interval, tolerance);
}
The Rstudio console has the following error messages.
> Rcpp::sourceCpp("R/cpp/testopt.cpp")
In file included from testopt.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:157:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/traits/traits.h:45:
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/traits/is_convertible.h:35:10: error: function cannot return function type 'Rcpp::Vector<14> (Rcpp::Vector<14>)'
static T MakeT() ;
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/internal/wrap.h:770:75: note: in instantiation of template class 'Rcpp::traits::is_convertible<Rcpp::Vector<14> (Rcpp::Vector<14>), SEXPREC *>' requested here
return wrap_dispatch_unknown(object, typename ::Rcpp::traits::is_convertible<T,SEXP>::type());
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/internal/wrap.h:787:20: note: in instantiation of function template specialization 'Rcpp::internal::wrap_dispatch_eigen<Rcpp::Vector<14> (Rcpp::Vector<14>)>' requested here
return wrap_dispatch_eigen(object, typename traits::is_eigen_base<T>::type());
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/internal/wrap.h:807:20: note: in instantiation of function template specialization 'Rcpp::internal::wrap_dispatch_unknown_importable<Rcpp::Vector<14> (Rcpp::Vector<14>)>' requested here
return wrap_dispatch_unknown_importable(object, typename ::Rcpp::traits::is_importer<T>::type());
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/internal/wrap_end.h:30:25: note: in instantiation of function template specialization 'Rcpp::internal::wrap_dispatch<Rcpp::Vector<14> (Rcpp::Vector<14>)>' requested here
return internal::wrap_dispatch( object, typename ::Rcpp::traits::wrap_type_traits<T>::wrap_category() ) ;
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/grow.h:44:26: note: in instantiation of function template specialization 'Rcpp::wrap<Rcpp::Vector<14> (Rcpp::Vector<14>)>' requested here
return grow( wrap(head), tail ) ;
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/grow.h:65:26: note: in instantiation of function template specialization 'Rcpp::internal::grow__dispatch<Rcpp::Vector<14> (Rcpp::Vector<14>)>' requested here
return internal::grow__dispatch(typename traits::is_named<T>::type(), head, y);
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/generated/grow__pairlist.h:45:9: note: in instantiation of function template specialization 'Rcpp::grow<Rcpp::Vector<14> (Rcpp::Vector<14>)>' requested here
return grow( t1, grow( t2, grow( t3, R_NilValue ) ) ) ;
^
/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/generated/Function__operator.h:45:20: note: in instantiation of function template specialization 'Rcpp::pairlist<Rcpp::Vector<14> (Rcpp::Vector<14>), Rcpp::Vector<14>, double>' requested here
return invoke(pairlist(t1, t2, t3), R_GlobalEnv);
^
testopt.cpp:13:20: note: in instantiation of function template specialization 'Rcpp::Function_Impl<PreserveStorage>::operator()<Rcpp::Vector<14> (Rcpp::Vector<14>), Rcpp::Vector<14>, double>' requested here
return optimize_r(f, interval, tolerance);
^
1 error generated.
make: *** [testopt.o] Error 1
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include" -I"/Users/gcn/Documents/workspace/ISIMIPData/R/cpp" -I/usr/local/include -fPIC -Wall -g -O2 -c testopt.cpp -o testopt.o
Error in Rcpp::sourceCpp("R/cpp/testopt.cpp") :
Error 1 occurred building shared library.
One of your problems here is that you assume that becomes a function you submit to compilation under Rcpp::sourceCpp() is callable under its exported name.
It is not. Try Rcpp::sourceCpp(..., verbose=TRUE), i.e. add that arguments, to see what is really called. Those you could pass around (using SEXP argunments and results, but they are unwieldy).
To prove, here is a 'working but useless' version of your code. If we pass f() from R too, everything is callable.
Morale: The interface still is SEXP .Call("name", SEXP a, SEXP b, ...) even if Rcpp hides that. No Free Lunch (TM). But as my comment hinted, there are optimization packages you can use with Rcpp.
Code
#include <Rcpp.h>
// [[Rcpp::export]]
Rcpp::List fTg_opt(Rcpp::Function f, const double optmin, const double optmax) {
Rcpp::Environment base("package:stats");
Rcpp::Function optimize_r = base["optimize"];
Rcpp::NumericVector interval = {optmin,optmax};
Rcpp::List res = optimize_r(f, interval);
return res;
}
/*** R
f <- function (x) (x - .33)^2
xmin <- optimize(f, c(0, 1), tol = 0.0001)
xmin
fTg_opt(f, 0, 1)
*/
Output
> Rcpp::sourceCpp("~/git/stackoverflow/68674076/question.cpp")
> f <- function (x) (x - .33)^2
> xmin <- optimize(f, c(0, 1), tol = 0.0001)
> xmin
$minimum
[1] 0.33
$objective
[1] 0
> fTg_opt(f, 0, 1)
$minimum
[1] 0.33
$objective
[1] 0

(M68k) Why is my value not getting passed into D0?

So I am writing a program and subroutine where this is basically the pseudocode.
int findmin(int* vals, int count){
if(count == 1){
return vals[0];
}else{
int minrest = findmin(vals+1,count-1);
if (minrest < vals[0]){
return minrest
}else{
return vals[0]
}
}
}
I basically have to put this into m68k assembly code. In the pictures is what i have so far. I think my logic is correct but for some reason all this does is printout my header and nothing else, I feel like for some reason I am not corectly storing my result into D0 where it should be. Is there a step I am missing or something that I am just completely off on? My prog4.s is my main that calls the subroutine
My prog4.s is my main that calls the subroutine
subroutine recursive function
The main code calls the subroutine like this:
pea vals
move.w D1, -(SP)
jsr findmin
adda.l #6, SP
The findmin subroutine makes next recursive call:
move.l A0, -(SP)
move.w D1, -(SP)
jsr findmin
adda.l #6, SP
The findmin subroutine retrieves its parameters like:
findmin:
link A6, #0
...
move.w 8(A6), D1
move.l 12(A6), A0 <<< Here is the error!
But wait, because of how you placed things on the stack, this is how the stack is laid out:
A6 RTS D1 A0
lower ==== ==== == ==== higher
^
SP == A6
The above shows that the word D1 is at 8(A6) and that the longword A0 is at 10(A6). That's 10 instead of 12.

RcppArmadillo: Error when calling cppFunction [duplicate]

I am working through the book "Seamless R and C++ Integration with Rcpp". I am using R version 3.1.0 on Ubuntu 12.04. I cannot figure out how to properly link the necessary libraries. I have the following code in R:
R> library(Rcpp)
R> library(RcppArmadillo)
R> suppressMessages(require(inline))
R> code <- '
+ arma::mat coeff = Rcpp::as<arma::mat>(a);
+ arma::mat errors = Rcpp::as<arma::mat>(u);
+ int m = errors.n_rows;
+ int n = errors.n_cols;
+ arma::mat simdata(m,n);
+ simdata.row(0) = arma::zeros<arma::mat>(1, n);
+ for (int row=1; row < m; row++) {
+ simdata.row(row) = simdata.row(row-1)*trans(coeff)
+ + errors.row(row);
+ }
+ return Rcpp::wrap(simdata);
+ '
R> rcppSim <- cxxfunction(signature(a="numeric", u="numeric"),
+ code, plugin="RcppArmadillo")
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [file167d1a7cd1ad.so] Error 1
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
1:
2: // includes from the plugin
3: #include <RcppArmadillo.h>
4: #include <Rcpp.h>
5:
6:
7: #ifndef BEGIN_RCPP
8: #define BEGIN_RCPP
9: #endif
10:
11: #ifndef END_RCPP
12: #define END_RCPP
13: #endif
14:
15: using namespace Rcpp;
16:
17:
18: // user includes
19:
20:
21: // declarations
22: extern "C" {
23: SEXP file167d1a7cd1ad( SEXP a, SEXP u) ;
24: }
25:
26: // definition
27:
28: SEXP file167d1a7cd1ad( SEXP a, SEXP u ){
29: BEGIN_RCPP
30:
31: arma::mat coeff = Rcpp::as<arma::mat>(a);
32: arma::mat errors = Rcpp::as<arma::mat>(u);
33: int m = errors.n_rows;
34: int n = errors.n_cols;
35: arma::mat simdata(m,n);
36: simdata.row(0) = arma::zeros<arma::mat>(1, n);
37: for (int row=1; row < m; row++) {
38: simdata.row(row) = simdata.row(row-1)*trans(coeff)
39: + errors.row(row);
40: }
41: return Rcpp::wrap(simdata);
42:
43: END_RCPP
44: }
45:
46:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created!
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [file167d1a7cd1ad.so] Error 1
Calls: cxxfunction -> compileCode
In addition: Warning message:
running command '/usr/lib/R/bin/R CMD SHLIB file167d1a7cd1ad.cpp 2>
file167d1a7cd1ad.cpp.err.txt' had status 1
Based on this response to a similar question,
http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2014-February/007245.html
it would appear that I simply need to install
the FORTRAN compiler. However, I have installed gfortran using the Ubuntu package manager and still receive the same error. From terminal:
$ dpkg -s gfortran
Package: gfortran
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 33
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Architecture: i386
Source: gcc-defaults (1.112ubuntu5)
Version: 4:4.6.3-1ubuntu5
Provides: fortran-compiler
Depends: cpp (>= 4:4.6.3-1ubuntu5), gcc (>= 4:4.6.3-1ubuntu5), gfortran-4.6
(>= 4.6.3-1~)
Suggests: gfortran-multilib, gfortran-doc
Description: GNU Fortran 95 compiler
This is the GNU Fortran 95 compiler, which compiles Fortran 95 on platforms
supported by the gcc compiler. It uses the gcc backend to generate optimized
code.
This is a dependency package providing the default GNU Fortran 95 compiler.
Original-Maintainer: Debian GCC Maintainers <debian-gcc#lists.debian.org>
I have also been unsuccessful trying to use the CxxFlags() and LdFlags() functions. Any suggestions are greatly appreciated.
Running sourceCpp() produces the following:
R> rcppSim <- sourceCpp("~/Dropbox/Rcpp/rcppSim.cpp")
rcppSim.cpp: In function ‘SEXPREC* file167d1a7cd1ad(SEXP, SEXP)’:
rcppSim.cpp:31:1: error: ‘arma’ has not been declared
rcppSim.cpp:31:11: error: expected ‘;’ before ‘coeff’
rcppSim.cpp:32:1: error: ‘arma’ has not been declared
rcppSim.cpp:32:11: error: expected ‘;’ before ‘errors’
rcppSim.cpp:33:9: error: ‘errors’ was not declared in this scope
rcppSim.cpp:35:1: error: ‘arma’ has not been declared
rcppSim.cpp:35:11: error: expected ‘;’ before ‘simdata’
rcppSim.cpp:36:1: error: ‘simdata’ was not declared in this scope
rcppSim.cpp:36:18: error: ‘arma’ has not been declared
rcppSim.cpp:36:30: error: ‘arma’ has not been declared
rcppSim.cpp:38:47: error: ‘coeff’ was not declared in this scope
rcppSim.cpp:38:52: error: ‘trans’ was not declared in this scope
make: *** [rcppSim.o] Error 1
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/lib/R/library/Rcpp/include"
-I"/usr/lib/R/library/RcppArmadillo/include" -I"/usr/lib/R/library/Rcpp/include"
-fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
-Werror=format-security -D_FORTIFY_SOURCE=2 -g -c rcppSim.cpp -o rcppSim.o
Error in sourceCpp("~/Dropbox/Rcpp/rcppSim.cpp") :
Error 1 occurred building shared library.
Running the dpkg command gives:
~$ dpkg -l | grep libgfortran | cut -c-75
ii libgfortran-4.7-dev 4.7.3-2ubuntu1~12.04
ii libgfortran-4.8-dev 4.8.1-2ubuntu1~12.04
ii libgfortran3 4.8.1-2ubuntu1~12.04
~$
Can you run the following command, please:
edd#max:~$ dpkg -l | grep libgfortran | cut -c-75
ii libgfortran-4.7-dev:amd64 4.7.3-7ubuntu3
ii libgfortran-4.8-dev:amd64 4.8.1-10ubuntu9
ii libgfortran3:amd64 4.8.1-10ubuntu9
edd#max:~$
You need the libgfortrain-$VERSION-dev package for your machine. At some point having gfortran implied this via r-base-dev and its dependence on build-essentials.
Edit: Version numbers will of course be different on your 12.04 release; this was from a machine running 13.10.
Edit 2, based on your update: Your use of sourceCpp() is incorrect. You are not telling Rcpp that you need Armadillo, so Rcpp responds by saying it does not know Armadillo. You can either use a Rcpp::depends() in the cpp file, or use the plugin= argument.
So here is how I would write the code you have above. You can then just call sourceCpp() on the file which will create a function rcppSim() you can call:
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
arma::mat rcppSim(arma::mat coeff, arma::mat errors) {
int m = errors.n_rows;
int n = errors.n_cols;
arma::mat simdata(m,n);
simdata.row(0) = arma::zeros<arma::mat>(1, n);
for (int row=1; row < m; row++) {
simdata.row(row) = simdata.row(row-1)*trans(coeff) + errors.row(row);
}
return simdata;
}

no matching function for call to 'WaveHC::WaveHC()' Arduino Error

I'm working on a arduino(uno) talking clock project. I'm using the code on this site : https://learn.adafruit.com/wave-shield-talking-clock/overview
add the WaveHC library when I get the following error :
Arduino:1.6.6 (Windows 10), Card:"Arduino/Genuino Uno"
TalkingClock:44: error: no matching function for call to 'WaveHC::WaveHC()'
WaveHC wave;
^
\Arduino\TalkingClock\TalkingClock.ino:44:12: note: candidates are:
In file included from \Arduino\TalkingClock\TalkingClock.ino:26:0:
\Arduino\libraries\WaveHC/WaveHC.h:113:3: note: WaveHC::WaveHC(HardwareSerial&)
WaveHC(HardwareSerial& serial);
^
\Arduino\libraries\WaveHC/WaveHC.h:113:3: note: candidate expects 1 argument, 0 provided
\Arduino\libraries\WaveHC/WaveHC.h:77:7: note: constexpr WaveHC::WaveHC(const WaveHC&)
class WaveHC
^
\Arduino\libraries\WaveHC/WaveHC.h:77:7: note: candidate expects 1 argument, 0 provided
\Arduino\libraries\WaveHC/WaveHC.h:77:7: note: constexpr WaveHC::WaveHC(WaveHC&&)
\Arduino\libraries\WaveHC/WaveHC.h:77:7: note: candidate expects 1 argument, 0 provided
TalkingClock:64: error: variable 'hours' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
*hours[] = { h12, h01, h02, h03, h04, h05, h06, h07, h08, h09, h10, h11 },
^
TalkingClock:65: error: variable 'mTens' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
*mTens[] = { m00, m10, m20, m30, m40, m50 },
^
TalkingClock:66: error: variable 'mTeens' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
*mTeens[] = { m11, m12, m13, m14, m15, m16, m17, m18, m19 },
^
TalkingClock:67: error: variable 'mTenX' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
*mTenX[] = { m0x, NULL, m2x, m3x, m4x, m5x },
^
TalkingClock:68: error: variable 'mins' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
*mins[] = { m1, m2, m3, m4, m5, m6, m7, m8, m9 },
^
TalkingClock:69: error: variable 'ampm' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
*ampm[] = { am, pm };
^
exit status 1
no matching function for call to 'WaveHC::WaveHC()'

Armadillo: solve with sp_mat

I'm writing a basic FEM program using Armadillo. I use sp_mat and vec as matrix and vector type. The problem is, that when I do solve(X, b) i get an error. Could it be that solve does not support sp_mat. Any alternatives except of using dense matrices? Below is the code, where the sp_mat doesn't compile. If I use the the commented line mat A instead it works fine.
int N = 3;
double h = 1./N;
//mat A = zeros<mat>(N+1,N+1);
sp_mat A(N+1,N+1);
for(int i=0;i<=N;i++) {
if(i>0) {A(i,i-1)=-1.;}
A(i,i)=2.;
if(i<N) {A(i,i+1)=-1.;}
}
A(N,N)=1;
vec b = zeros(N+1);
for(int i=0;i<=N;i++) {
b(i)=h;
}
vec zeta = solve(A,b);
cout << zeta;
The error:
make all
Building file: ../src/FEM.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/FEM.d" -MT"src/FEM.d" -o "src/FEM.o" "../src/FEM.cpp"
../src/FEM.cpp: In function ‘int main()’:
../src/FEM.cpp:37:22: error: no matching function for call to ‘solve(arma::sp_mat&, arma::vec&)’
vec zeta = solve(A,b);
^
../src/FEM.cpp:37:22: note: candidates are:
In file included from /usr/include/armadillo:397:0,
from ../src/FEM.cpp:10:
/usr/include/armadillo_bits/fn_solve.hpp:25:1: note: template<class T1, class T2> const arma::Glue<T1, T2, arma::glue_solve> arma::solve(const arma::Base<typename T1::elem_type, T1>&, const arma::Base<typename T1::elem_type, T2>&, bool, const typename arma::arma_blas_type_only<typename T1::elem_type>::result*)
solve
^
/usr/include/armadillo_bits/fn_solve.hpp:25:1: note: template argument deduction/substitution failed:
../src/FEM.cpp:37:22: note: ‘arma::sp_mat {aka arma::SpMat<double>}’ is not derived from ‘const arma::Base<typename T1::elem_type, T1>’
vec zeta = solve(A,b);
^
In file included from /usr/include/armadillo:397:0,
from ../src/FEM.cpp:10:
/usr/include/armadillo_bits/fn_solve.hpp:44:1: note: template<class T1, class T2> const arma::Glue<T1, T2, arma::glue_solve> arma::solve(const arma::Base<typename T1::elem_type, T1>&, const arma::Base<typename T1::elem_type, T2>&, const char*, const typename arma::arma_blas_type_only<typename T1::elem_type>::result*)
solve
^
/usr/include/armadillo_bits/fn_solve.hpp:44:1: note: template argument deduction/substitution failed:
../src/FEM.cpp:37:22: note: ‘arma::sp_mat {aka arma::SpMat<double>}’ is not derived from ‘const arma::Base<typename T1::elem_type, T1>’
vec zeta = solve(A,b);
^
In file included from /usr/include/armadillo:397:0,
from ../src/FEM.cpp:10:
/usr/include/armadillo_bits/fn_solve.hpp:67:1: note: template<class T1, class T2> const arma::Glue<T1, T2, arma::glue_solve_tr> arma::solve(const arma::Op<T1, arma::op_trimat>&, const arma::Base<typename T1::elem_type, T2>&, bool, const typename arma::arma_blas_type_only<typename T1::elem_type>::result*)
solve
^
/usr/include/armadillo_bits/fn_solve.hpp:67:1: note: template argument deduction/substitution failed:
../src/FEM.cpp:37:22: note: ‘arma::sp_mat {aka arma::SpMat<double>}’ is not derived from ‘const arma::Op<T1, arma::op_trimat>’
vec zeta = solve(A,b);
^
In file included from /usr/include/armadillo:397:0,
from ../src/FEM.cpp:10:
/usr/include/armadillo_bits/fn_solve.hpp:87:1: note: template<class T1, class T2> const arma::Glue<T1, T2, arma::glue_solve_tr> arma::solve(const arma::Op<T1, arma::op_trimat>&, const arma::Base<typename T1::elem_type, T2>&, const char*, const typename arma::arma_blas_type_only<typename T1::elem_type>::result*)
solve
^
/usr/include/armadillo_bits/fn_solve.hpp:87:1: note: template argument deduction/substitution failed:
../src/FEM.cpp:37:22: note: ‘arma::sp_mat {aka arma::SpMat<double>}’ is not derived from ‘const arma::Op<T1, arma::op_trimat>’
vec zeta = solve(A,b);
^
In file included from /usr/include/armadillo:397:0,
from ../src/FEM.cpp:10:
/usr/include/armadillo_bits/fn_solve.hpp:110:1: note: template<class T1, class T2> bool arma::solve(arma::Mat<typename T1::elem_type>&, const arma::Base<typename T1::elem_type, T1>&, const arma::Base<typename T1::elem_type, T2>&, bool, const typename arma::arma_blas_type_only<typename T1::elem_type>::result*)
solve
^
/usr/include/armadillo_bits/fn_solve.hpp:110:1: note: template argument deduction/substitution failed:
../src/FEM.cpp:37:22: note: ‘arma::sp_mat {aka arma::SpMat<double>}’ is not derived from ‘arma::Mat<typename T1::elem_type>’
vec zeta = solve(A,b);
^
In file included from /usr/include/armadillo:397:0,
from ../src/FEM.cpp:10:
/usr/include/armadillo_bits/fn_solve.hpp:139:1: note: template<class T1, class T2> bool arma::solve(arma::Mat<typename T1::elem_type>&, const arma::Base<typename T1::elem_type, T1>&, const arma::Base<typename T1::elem_type, T2>&, const char*, const typename arma::arma_blas_type_only<typename T1::elem_type>::result*)
solve
^
/usr/include/armadillo_bits/fn_solve.hpp:139:1: note: template argument deduction/substitution failed:
../src/FEM.cpp:37:22: note: ‘arma::sp_mat {aka arma::SpMat<double>}’ is not derived from ‘arma::Mat<typename T1::elem_type>’
vec zeta = solve(A,b);
^
make: *** [src/FEM.o] Error 1
Sparse matrix support in Armadillo is not yet complete.
You can use ARPACK for (eigen-)decomposition of sparse matrix. Sparse matrix solvers will probably comes in the next release which may use the CXSparse library from the SuiteSparse project.
As of version 5.0, Armadillo has the spsolve() function for solving sparse systems.

Resources