0

I am trying to compile an Rcpp package that relies on the external library HDFql.

First, I tried compiling a plain .cpp file following the directions in the reference manual, which worked fine:

g++ example.cpp -I./include/HDFql ./HDFql/libHDFql.a -fopenmp -ldl

where the ./include/HDFql folder contains the header files and ./HDFql/libHDFql.a is the static library.

Then I tried doing the equivalent in an Rcpp package. My package directory structure is

|- R
  |- script. r
|- src
  |- HDFql
    |- libHDFql.a
  |- example.cpp
  |- Makevars
|-inst
  |- include
    |- HDFql
      |- ... header files...

Where the contents of Makevars is

PKG_CPPFLAGS = -I../inst/include/HDFql/
PKG_LIBS = ./HDFql/libHDFql.a
LDLIBS = -fopenmp -ldl

I also added #include <Rcpp.h> to example.cpp. Running devtools::document() yields

../inst/include/HDFql/H5public.h:156:19: error: conflicting declaration ‘typedef long long int ssize_t’ typedef long long ssize_t;

Which I don't understand at all. Can anyone explain what is happening here?

EDIT link to Github repository

mikeck
  • 3,534
  • 1
  • 26
  • 39
  • is your project on github? – SymbolixAU Apr 12 '18 at 22:58
  • Looks like Rcpp's `typedef` for `long long` and the one for your library source disagree. So make the definition in your library conditional via `#ifndef ....` ? – Dirk Eddelbuettel Apr 12 '18 at 22:59
  • @SymbolixAU see my edit (link at bottom). – mikeck Apr 12 '18 at 23:16
  • @Dirk, not sure what you mean? HDFql is an external library someone else has developed... or is this something I would put in `example.cpp`? – mikeck Apr 12 '18 at 23:19
  • @mikeck: https://github.com/mkoohafkan/RcppHDFql/blob/f112427521bcf36f914429f2b743f4828204a09b/inst/include/HDFql/H5public.h#L156 You can define something in your `example.cpp` before the `#include` to avoid this redefinition. That should do the trick. – Dirk Eddelbuettel Apr 12 '18 at 23:39
  • Sorry @Dirk, I still don't understand. The headers in include/HDFql are part of the HDFql distribution along with libHDFql.a. I thought include guards are used to prevent the same header being included twice? But in this case I have two header files using the same name for different purposes so I don't know how to proceed. – mikeck Apr 13 '18 at 02:26
  • 1
    According to HDFql release notes (http://www.hdfql.com/resources/RELEASE.txt), the issue (of conflicting with other C/C++ header dependencies) has been solved in version 2.0.0 – SOG Mar 28 '19 at 11:33

0 Answers0