[Rcpp-devel] #include gretl libraries in Rcpp
Romain Francois
romain at r-enthusiasts.com
Thu Dec 20 01:04:28 CET 2012
Welcome in macro hell.
Try this:
#include <gretl/libgretl.h>
#include <gretl/kalman.h>
#undef PARENT
#include <Rcpp.h>
So one of these headers is defining a macro "PARENT" that conflicts with
the name PARENT used in any.h. This should take care of it.
Romain
Le 20/12/12 00:56, jean.p at hushmail.com a écrit :
> thanks for the quick reply!
>
> first option did not change anything and second option seems to create
> new errors linked to Rcpp:
>
> jean at desktop:~/Documents/code experiments/gretl$ make
>
> PKG_CPPFLAGS="-I/usr/share/R/include -I/usr/lib/R/library/Rcpp/include
> -I/usr/include/libxml2 -I/usr/include/glib-2.0
> -I/usr/lib/glib-2.0/include " PKG_LIBS="-L/usr/lib64/R/lib -lR
> -L/usr/lib/R/library/Rcpp/lib -lRcpp
> -Wl,-rpath,/usr/lib/R/library/Rcpp/lib -fopenmp -lgretl-1.0 -lxml2
> -lfftw3 -lm -lglib-2.0 " R CMD SHLIB test2.cpp
>
> make[1]: Entering directory `/home/jean/Documents/code experiments/gretl'
>
> g++ -I/usr/share/R/include -DNDEBUG -I/usr/share/R/include
> -I/usr/lib/R/library/Rcpp/include -I/usr/include/libxml2
> -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -fpic -O3
> -pipe -g -c test2.cpp -o test2.o
> In file included from
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/functions.h:34,
> from
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/sugar.h:30,
> from /usr/lib/R/library/Rcpp/include/Rcpp.h:68,
> from test2.cpp:4:
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/any.h:33:36: error:
> macro "PARENT" requires 2 arguments, but only 1 given
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/any.h:62:36: error:
> macro "PARENT" requires 2 arguments, but only 1 given
> In file included from
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/functions.h:35,
> from
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/sugar.h:30,
> from /usr/lib/R/library/Rcpp/include/Rcpp.h:68,
> from test2.cpp:4:
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/all.h:33:36: error:
> macro "PARENT" requires 2 arguments, but only 1 given
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/all.h:64:36: error:
> macro "PARENT" requires 2 arguments, but only 1 given
> In file included from
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/functions.h:34,
> from
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/sugar.h:30,
> from /usr/lib/R/library/Rcpp/include/Rcpp.h:68,
> from test2.cpp:4:
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/any.h: In
> constructor ‘Rcpp::sugar::Any<NA, T>::Any(const Rcpp::VectorBase<10,
> LHS_NA, LHS_T>&)’:
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/any.h:33: error:
> expected ‘(’ before ‘,’ token
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/any.h: In
> constructor ‘Rcpp::sugar::Any<false, T>::Any(const Rcpp::VectorBase<10,
> false, LHS_T>&)’:
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/any.h:62: error:
> expected ‘(’ before ‘,’ token
> In file included from
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/functions.h:35,
> from
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/sugar.h:30,
> from /usr/lib/R/library/Rcpp/include/Rcpp.h:68,
> from test2.cpp:4:
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/all.h: In
> constructor ‘Rcpp::sugar::All<NA, T>::All(const Rcpp::VectorBase<10,
> LHS_NA, LHS_T>&)’:
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/all.h:33: error:
> expected ‘(’ before ‘,’ token
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/all.h: In
> constructor ‘Rcpp::sugar::All<false, T>::All(const Rcpp::VectorBase<10,
> false, LHS_T>&)’:
> /usr/lib/R/library/Rcpp/include/Rcpp/sugar/functions/all.h:64: error:
> expected ‘(’ before ‘,’ token
>
>
> On Thursday, December 20, 2012 at 12:48 AM, "Romain Francois"
> <romain at r-enthusiasts.com> wrote:
>
> The extern "C" looks suspicious. What happens if you don't include it ?
>
> e.g.
>
> #include <Rcpp.h>
> #include <gretl/libgretl.h>
> #include <gretl/kalman.h>
>
> or perhaps:
>
> #include <gretl/libgretl.h>
> #include <gretl/kalman.h>
> #include <Rcpp.h>
>
> Romain
>
> Le 20/12/12 00:39, jean.p at hushmail.com a écrit :
> > Hi,
> >
> > I am having trouble getting Rcpp to compile c++ files including headers
> > from the gretl statistical libraries
> >
> > for instance, here are the first lines of a test cpp file I have been
> > trying to compile:
> >
> > #include <Rcpp.h>
> >
> > extern "C" {
> > #include <gretl/libgretl.h>
> > #include <gretl/kalman.h>
> > }
> >
> > now, here is the result of a make command in linux (debian), with the
> > error messages focussing on the lines of code where the #include are
> > located:
> >
> > jean at desktop:~/Documents/code experiments/gretl$ make
> >
> > PKG_CPPFLAGS="-I/usr/share/R/include -I/usr/lib/R/library/Rcpp/include
> > -I/usr/include/libxml2 -I/usr/include/glib-2.0
> > -I/usr/lib/glib-2.0/include " PKG_LIBS="-L/usr/lib64/R/lib -lR
> > -L/usr/lib/R/library/Rcpp/lib -lRcpp
> > -Wl,-rpath,/usr/lib/R/library/Rcpp/lib -fopenmp -lgretl-1.0 -lxml2
> > -lfftw3 -lm -lglib-2.0 " R CMD SHLIB test2.cpp
> >
> > make[1]: Entering directory `/home/jean/Documents/code experiments/gretl'
> >
> > g++ -I/usr/share/R/include -DNDEBUG -I/usr/share/R/include
> > -I/usr/lib/R/library/Rcpp/include -I/usr/include/libxml2
> > -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -fpic -O3
> > -pipe -g -c test2.cpp -o test2.o
> >
> > In file included from /usr/include/gretl/libgretl.h:384,
> > from test2.cpp:4:
> > /usr/include/gretl/genmain.h:33: error: expected identifier before
> > numeric constant
> > /usr/include/gretl/genmain.h:33: error: expected ‘}’ before numeric constant
> > /usr/include/gretl/genmain.h:33: error: expected unqualified-id before
> > numeric constant
> > /usr/include/gretl/genmain.h:49: error: expected constructor,
> > destructor, or type conversion before ‘;’ token
> > /usr/include/gretl/genmain.h:59: error: ‘R_MAX’ was not declared in this
> > scope
> > test2.cpp:6: error: expected declaration before ‘}’ token
> > make[1]: *** [test2.o] Error 1
> > make[1]: Leaving directory `/home/jean/Documents/code experiments/gretl'
> > make: *** [test2.o] Error 1
> >
> > any guidance would be really appreciated!
> >
> > many thanks,
> > jean
> >
> >
> > _______________________________________________
> > Rcpp-devel mailing list
> > Rcpp-devel at lists.r-forge.r-project.org
> >https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
> >
>
>
> --
> Romain Francois
> Professional R Enthusiast
> +33(0) 6 28 91 30 30
>
> R Graph Gallery: http://gallery.r-enthusiasts.com
>
> blog: http://romainfrancois.blog.free.fr
> |- http://bit.ly/RE6sYH : OOP with Rcpp modules
> `- http://bit.ly/Thw7IK : Rcpp modules more flexible
>
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://gallery.r-enthusiasts.com
blog: http://romainfrancois.blog.free.fr
|- http://bit.ly/RE6sYH : OOP with Rcpp modules
`- http://bit.ly/Thw7IK : Rcpp modules more flexible
More information about the Rcpp-devel
mailing list