[Rcpp-devel] Specifying additional include path in Rcpp package
Dirk Eddelbuettel
edd at debian.org
Thu Jul 18 17:14:56 CEST 2013
Hi Rainer,
On 18 July 2013 at 16:51, Rainer M Krug wrote:
| Hi
|
| I am sure thsi has been answered or is in the manuals, but I just can't
| find it - I probably made a stupid mistake.
|
| But I don't manage to specify additional include paths in a package using Rcpp.
|
| in my grassRLink.h file I have:
|
| ,----
| | #ifndef _grassRLink_grassRLink_H
| | #define _grassRLink_grassRLink_H
| |
| | #include <Rcpp.h>
| |
| | #include <stdio.h>
| | #include <stdlib.h>
| |
| | #include <grass/gis.h>
| | #include <grass/raster.h>
| | #include <grass/glocale.h>
| |
| | using namespace Rcpp;
| |
| | RcppExport SEXP readRast(String name, String mapset, int row, int col) ;
| | #endif
| `----
|
| and to find the files grass/gis.h, grass/raster.h and grass/glocale.h I
| have the following in y Makevars
|
| ,----
| | #!/bin/bash
| | ## Use the R_HOME indirection to support installations of multiple R version
| | PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`
| | PKG_LIBS = $PKG_LIBS:/Applications/GRASS/GRASS-7.0.app/Contents/MacOS/include/
That is for __linking__ but not compiling and hence does nothing for header
files.
You want to set PKG_CXXFLAGS, or PKG_CPPFLAGS.
One (in my eyes) easy way is to look at existing packages... Pick one where
you know an external library and headers are used.
| | ## some commentsAs an alternative, one can also add this code in a file 'configure'
| `----
|
| with the idea that the include path is added. But when I use load_all(.)
| to laod the package, I get the following error:
|
| ,----
| | > load_all(".", recompile=TRUE)
| | Loading grassRLink
| | Re-compiling grassRLink
| | '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD INSTALL \
| | '/Users/rainerkrug/Documents/Projects/grassRLink' \
| | --library='/var/folders/50/wcr5bjwn75q595n6x82gxj280000gn/T//RtmpgWwh9v' \
| | --no-R --no-data --no-help --no-demo --no-inst --no-docs --no-exec \
| | --no-multiarch --no-test-load --preclean
| |
| | * installing *source* package 'grassRLink' ...
| | ** libs
| | llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I"/Users/rainerkrug/Library/R/3.0/library/Rcpp/include" -UNDEBUG -Wall -pedantic -g -O0 -fPIC -mtune=core2 -g -O2 -c RcppExports.cpp -o RcppExports.o
| | llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I"/Users/rainerkrug/Library/R/3.0/library/Rcpp/include" -UNDEBUG -Wall -pedantic -g -O0 -fPIC -mtune=core2 -g -O2 -c grassRLink.cpp -o grassRLink.o
| | In file included from grassRLink.cpp:2:
| | grassRLink.h:10:23: error: grass/gis.h: No such file or directory
| | grassRLink.h:11:26: error: grass/raster.h: No such file or directory
| | grassRLink.h:12:27: error: grass/glocale.h: No such file or directory
| | grassRLink.cpp: In function 'Rcpp::NumericVector readRast(Rcpp::String, Rcpp::String, int, int)':
| | grassRLink.cpp:7: error: new declaration 'Rcpp::NumericVector readRast(Rcpp::String, Rcpp::String, int, int)'
| | grassRLink.h:28: error: ambiguates old declaration 'SEXPREC* readRast(Rcpp::String, Rcpp::String, int, int)'
| | grassRLink.cpp:9: error: 'RASTER_MAP_TYPE' was not declared in this scope
| | grassRLink.cpp:9: error: expected `;' before 'data_type'
| | grassRLink.cpp:16: error: 'G_gisinit' was not declared in this scope
| | grassRLink.cpp:19: error: 'Rast_open_old' was not declared in this scope
| | grassRLink.cpp:22: error: 'data_type' was not declared in this scope
| | grassRLink.cpp:22: error: 'Rast_map_type' was not declared in this scope
| | grassRLink.cpp:25: error: 'Rast_allocate_buf' was not declared in this scope
| | grassRLink.cpp:28: error: 'Rast_window_rows' was not declared in this scope
| | grassRLink.cpp:29: error: 'Rast_window_cols' was not declared in this scope
| | grassRLink.cpp:34: error: 'Rast_get_row' was not declared in this scope
| | grassRLink.cpp:40: error: 'CELL_TYPE' was not declared in this scope
| | grassRLink.cpp:42: error: 'FCELL_TYPE' was not declared in this scope
| | grassRLink.cpp:44: error: 'DCELL_TYPE' was not declared in this scope
| | grassRLink.cpp:12: warning: unused variable 'nrow'
| | grassRLink.cpp:12: warning: unused variable 'ncol'
| | grassRLink.cpp:49: warning: no return statement in function returning non-void
| | make: *** [grassRLink.o] Error 1
| | ERROR: compilation failed for package 'grassRLink'
| | * removing '/private/var/folders/50/wcr5bjwn75q595n6x82gxj280000gn/T/RtmpgWwh9v/grassRLink'
| | * restoring previous '/private/var/folders/50/wcr5bjwn75q595n6x82gxj280000gn/T/RtmpgWwh9v/grassRLink'
| | Error: Command failed (1)
| | >
| `----
|
| telling me that the additional header files are not found, even though
| the path seems to be added:
|
| ,----
| | -I/Library/Frameworks/R.framework/Resources/include
| `----
Well ... are the grass/* files in that directory?
| It is probably my limited C / C++ expertise, but wat is going on here?
|
| I am working on OS X Mountain Lion, gcc is installed via homebrew, and I
| can compile other packages without problems.
"Other packages" may have working configurations, yours does not yet it seems.
Dirk
| You can find the package at github:
|
| https://github.com/rkrug/grassRLink
|
| Any suggestions?
|
| Thanks,
|
| Rainer
|
| --
| Rainer M. Krug
|
| email: RMKrug<at>gmail<dot>com
| application/pgp-signature [Press RETURN to save to a file]
|
| ----------------------------------------------------------------------
| _______________________________________________
| 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
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list