It fails for me on Linux as well:

$ clang++-7  -I"/usr/local/R/3.5/include" -DNDEBUG   
-I"/usr/local/R/site-lib/3.5/Rcpp/include" -I"/data/users/su" 
-I/usr/local/include   -fpic  -g -O2  -c t.cpp -o t.o
In file included from t.cpp:1:
In file included from /usr/local/R/site-lib/3.5/Rcpp/include/Rcpp.h:27:
In file included from /usr/local/R/site-lib/3.5/Rcpp/include/RcppCommon.h:168:
In file included from /usr/local/R/site-lib/3.5/Rcpp/include/Rcpp/as.h:25:
/usr/local/R/site-lib/3.5/Rcpp/include/Rcpp/internal/Exporter.h:31:30: error: 
reference member 't' binds to a temporary object whose lifetime would be 
shorter than the lifetime of the
      constructed object
                    Exporter( SEXP x ) : t(x){}
                                           ^
/usr/local/R/site-lib/3.5/Rcpp/include/Rcpp/as.h:87:41: note: in instantiation 
of member function 'Rcpp::traits::Exporter<const Rcpp::Vector<14, 
PreserveStorage> &>::Exporter' requested here
            ::Rcpp::traits::Exporter<T> exporter(x);
                                        ^
/usr/local/R/site-lib/3.5/Rcpp/include/Rcpp/as.h:152:26: note: in instantiation 
of function template specialization 'Rcpp::internal::as<const Rcpp::Vector<14, 
PreserveStorage> &>' requested
      here
        return internal::as<T>(x, typename 
traits::r_type_traits<T>::r_category());
                         ^
/usr/local/R/site-lib/3.5/Rcpp/include/Rcpp/module/Module_generated_Constructor.h:58:13:
 note: in instantiation of function template specialization
      'Rcpp::as<const Rcpp::Vector<14, PreserveStorage> &>' requested here
            as<U0>(args[0]),
            ^
/usr/local/R/site-lib/3.5/Rcpp/include/Rcpp/module/Module_generated_class_constructor.h:91:29:
 note: in instantiation of member function 'Rcpp::Constructor_2<MyModel, const 
Rcpp::Vector<14,
      PreserveStorage> &, int>::get_new' requested here
        AddConstructor( new Constructor_2<Class,U0,U1> , valid, docstring ) ;
                            ^
t.cpp:26:4: note: in instantiation of function template specialization 
'Rcpp::class_<MyModel>::constructor<const Rcpp::Vector<14, PreserveStorage> &, 
int>' requested here
  .constructor<const Rcpp::NumericVector &, int>()
   ^
/usr/local/R/site-lib/3.5/Rcpp/include/Rcpp/internal/Exporter.h:35:9: note: 
reference member declared here
                    T t ;
                      ^
1 error generated.


[Ubuntu 18.04.1 LTS; clang 7.0.0-3~ubuntu0.18.04.1]


> On May 7, 2019, at 9:33 PM, Dirk Eddelbuettel <e...@debian.org> wrote:
> 
> 
> On 6 May 2019 at 11:45, Robin GIRARD wrote:
> | Dear all, I created a small example that reproduces my error below. It has 
> to do with my use of module with  .constructor<const Rcpp::NumericVector &, 
> int>() with Rcpp::NumericVector. I guess I’m not doing things the right way 
> but since it is working on windows and used to work until now with my Mac … 
> | 
> | Thanks in advance for your help (below the simple test and the error 
> obtained) 
> | Regards
> | Robin
> | 
> | #include <Rcpp.h>
> | using namespace Rcpp;
> | 
> | class MyModel
> | {
> | public:
> |   double a;
> |   ~MyModel();
> |   MyModel();
> |   MyModel(const Rcpp::NumericVector& ModelData, int temp);
> | };
> | 
> | RCPP_EXPOSED_CLASS(MyModel)
> |   
> |   MyModel::~MyModel() 
> |   {}
> | MyModel::MyModel() : a(0) 
> | {}
> | MyModel::MyModel(const Rcpp::NumericVector& ModelData, int temp) : a(0)
> | {}
> | 
> | RCPP_MODULE(MyModel){
> |   
> |   Rcpp::class_<MyModel>("MyModel")
> |   .constructor()
> |   .constructor<const Rcpp::NumericVector &, int>()
> |   ;
> | }
> 
> Compiles fine for me:
> 
> R> sourceCpp("/tmp/robin.cpp", verbose=TRUE, rebuild=TRUE)
> 
> Generated extern "C" functions 
> --------------------------------------------------------
> 
> 
> #include <Rcpp.h>
> 
> Generated R functions 
> -------------------------------------------------------
> 
> `.sourceCpp_22_DLLInfo` <- 
> dyn.load('/tmp/RtmpduezeN/sourceCpp-x86_64-pc-linux-gnu-1.0.1.2/sourcecpp_438853e7adda/sourceCpp_24.so')
> 
> library(Rcpp)
> populate( Rcpp::Module("MyModel",`.sourceCpp_22_DLLInfo`), environment() ) 
> 
> rm(`.sourceCpp_22_DLLInfo`)
> 
> Building shared library
> --------------------------------------------------------
> 
> DIR: 
> /tmp/RtmpduezeN/sourceCpp-x86_64-pc-linux-gnu-1.0.1.2/sourcecpp_438853e7adda
> 
> /usr/lib/R/bin/R CMD SHLIB -o 'sourceCpp_24.so' --preclean  'robin.cpp'  
> ccache g++ -I"/usr/share/R/include" -DNDEBUG   
> -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/tmp"   -fpic  -g -O3 -Wall 
> -pipe  -Wno-misleading-indentation -Wno-unused -Wno-ignored-attributes 
> -Wno-class-memaccess -c robin.cpp -o robin.o
> ccache g++ -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions 
> -Wl,-z,relro -o sourceCpp_24.so robin.o -L/usr/lib/R/lib -lR
> R>
> 
> Dirk
> 
> | Compilation error : 
> | 
> | /usr/local/clang7/bin/clang++  -Wall 
> -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   
> -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include"
>  -I"/Users/robin.girard/Documents/Code/Packages/test_modules/Test2/src" 
> -I"/Users/robin.girard/Documents/Code/Packages/test_modules/Test2/src/../inst/include"
>  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 
> -I/usr/local/include  -fPIC  -Wall -g -O2  -c test.cpp -o test.o
> | In file included from test.cpp:1:
> | In file included from 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp.h:27:
> | In file included from 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/RcppCommon.h:168:
> | In file included from 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/as.h:25:
> | 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/internal/Exporter.h:31:30:
>  error: reference member 't' binds to a temporary object whose lifetime would 
> be shorter than the lifetime of the constructed object
> |                     Exporter( SEXP x ) : t(x){}
> |                                            ^
> | 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/as.h:87:41:
>  note: in instantiation of member function 'Rcpp::traits::Exporter<const 
> Rcpp::Vector<14, PreserveStorage> &>::Exporter' requested here
> |             ::Rcpp::traits::Exporter<T> exporter(x);
> |                                         ^
> | 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/as.h:152:26:
>  note: in instantiation of function template specialization 
> 'Rcpp::internal::as<const Rcpp::Vector<14, PreserveStorage> &>' requested here
> |         return internal::as<T>(x, typename 
> traits::r_type_traits<T>::r_category());
> |                          ^
> | 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/module/Module_generated_Constructor.h:58:13:
>  note: in instantiation of function template specialization 'Rcpp::as<const 
> Rcpp::Vector<14, PreserveStorage> &>' requested here
> |             as<U0>(args[0]),
> |             ^
> | 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/module/Module_generated_class_constructor.h:91:29:
>  note: in instantiation of member function 'Rcpp::Constructor_2<MyModel, 
> const Rcpp::Vector<14, PreserveStorage> &, int>::get_new' requested here
> |         AddConstructor( new Constructor_2<Class,U0,U1> , valid, docstring ) 
> ;
> |                             ^
> | test.cpp:26:4: note: in instantiation of function template specialization 
> 'Rcpp::class_<MyModel>::constructor<const Rcpp::Vector<14, PreserveStorage> 
> &, int>' requested here
> |   .constructor<const Rcpp::NumericVector &, int>()
> |    ^
> | 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/internal/Exporter.h:35:9:
>  note: reference member declared here
> |                     T t ;
> | 1 error generated.
> | make: *** [test.o] Error 1
> | Error in Rcpp::sourceCpp("src/test.cpp") : 
> |   Error 1 occurred building shared library.
> | 
> | 
> | 
> | > Le 3 mai 2019 à 08:41, Robin GIRARD <robin.gir...@mines-paristech.fr> a 
> écrit :
> | > 
> | > I found a way to solve my RcppArmadillo problem here 
> https://stackoverflow.com/questions/51761599/cannot-find-stdio-h 
> <https://stackoverflow.com/questions/51761599/cannot-find-stdio-h>
> | > I don’t really understand what happened because I had the file. 
> | > The other error is still here
> | > Regards
> | > Robin
> | > 
> | >> Le 3 mai 2019 à 08:32, Robin GIRARD <robin.gir...@mines-paristech.fr 
> <mailto:robin.gir...@mines-paristech.fr>> a écrit :
> | >> 
> | >> Dear Simon, 
> | >> 
> | >> **regarding RcppArmadillo build from source pb**  the config.log is 
> attached and points the following error while checking something about cross  
> compilation.
> | >> In file included from conftest.cpp:9:
> | >> /usr/local/clang7/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' 
> file not found
> | >> #include_next <stdio.h>
> | >> 
> | >> But this file exists. 
> | >> 
> | >> ** regarding my compilation error** it is obtained while trying to build 
> the module file, when calling #include "Rcpp.h » (line 4 of file Client.hpp) 
> | >> /usr/local/clang7/bin/clang++  -Wall 
> -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -std=c++11 
> -I../inst/include/ 
> -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include"
>  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 
> -I/usr/local/include  -fPIC  -Wall -g -O2  -c mod_client.cc 
> <http://mod_client.cc/> -o mod_client.o
> | >> 
> | >> In file included from mod_client.cc <http://mod_client.cc/>:1:
> | >> In file included from ../inst/include/Client.hpp:4:
> | >> In file included from 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp.h:27:
> | >> In file included from 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/RcppCommon.h:168:
> | >> In file included from 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/as.h:25:
> | >> 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/internal/Exporter.h:31:30:
>  error: reference member 't' binds to a temporary object whose lifetime would 
> be shorter than the lifetime of the constructed object
> | >>                     Exporter( SEXP x ) : t(x){}
> | >> 
> | >> Thanks in advance for your help
> | >> Regards
> | >> Robin
> | >> 
> | >> <config.log>
> | >> 
> | >>> Le 2 mai 2019 à 23:18, Simon Urbanek <simon.urba...@r-project.org 
> <mailto:simon.urba...@r-project.org>> a écrit :
> | >>> 
> | >>> Robin,
> | >>> 
> | >>> this is unlikely a Mac issue, merely newer compilers give you better 
> error handling pointing to issues in the code that may not have been detected 
> before. If you post the code we can have a look.
> | >>> 
> | >>> Also check your tools - the RcppArmadillo error points out that your 
> compiler setup is broken since it cannot create runnable executable. Check 
> config.log for details.
> | >>> 
> | >>> Cheers,
> | >>> Simon
> | >>> 
> | >>> 
> | >>> 
> | >>>> On May 2, 2019, at 1:04 PM, Robin GIRARD 
> <robin.gir...@mines-paristech.fr <mailto:robin.gir...@mines-paristech.fr>> 
> wrote:
> | >>>> 
> | >>>> Dear all, avec a Mac update today I obtained the following error while 
> compiling a package of mine using Rcpp : 
> | >>>> 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/Rcpp/internal/Exporter.h:31:30:
>  error: reference member 't' binds to a temporary object whose lifetime would 
> be shorter than the lifetime of the constructed object
> | >>>>                    Exporter( SEXP x ) : t(x){}
> | >>>> 
> | >>>> I’m pretty sure this has something to do with Mac, I updated the 
> Command line tool, I manage to compile simple examples with sourceRcpp 
> (trying to follow instructions here 
> http://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-macos/
>  
> <http://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-macos/>)
>  I’m still trying to reproduce my error on a simple example. 
> | >>>> I have R 3.6 and clang7 installed. 
> | >>>> 
> | >>>> Another strange point (might be connected) is that when I try to 
> install RcppArmadillo from source (as suggested in link above with 
> install.packages("", type = "source »)) it gives something about cross 
> compiling:
> | >>>> 
> | >>>> checking whether the C++ compiler works... yes
> | >>>> checking for C++ compiler default output file name... a.out
> | >>>> checking for suffix of executables... 
> | >>>> checking whether we are cross compiling... configure: error: in 
> `/private/var/folders/zt/7cz1y9md79l_h08bbqymt4w9z8xlw7/T/Rtmpgi7WQZ/R.INSTALL4f4110aa3f/RcppArmadillo':
> | >>>> configure: error: cannot run C++ compiled programs.
> | >>>> If you meant to cross compile, use `--host'.
> | >>>> See `config.log' for more details
> | >>>> ERROR: configuration failed for package ‘RcppArmadillo’
> | >>>> 
> | >>>> 
> | >>>> Thanks in advance for your help
> | >>>> Regards
> | >>>> Robin
> | >>>> 
> | >>>> 
> | >>>> _______________________________________________
> | >>>> Rcpp-devel mailing list
> | >>>> Rcpp-devel@lists.r-forge.r-project.org 
> <mailto:Rcpp-devel@lists.r-forge.r-project.org>
> | >>>> 
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel 
> <https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel>
> | >>> 
> | >> 
> | > 
> | > _______________________________________________
> | > Rcpp-devel mailing list
> | > Rcpp-devel@lists.r-forge.r-project.org
> | > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
> | 
> | _______________________________________________
> | Rcpp-devel mailing list
> | Rcpp-devel@lists.r-forge.r-project.org
> | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
> -- 
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
> 

_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to