简体   繁体   中英

Rcpp: Trouble with linking to Shogun C++ files

I am writing an R package and I am trying to include some of the functionality of the Shogun toolbox for machine learning . I first included the shogun folder which contains the C++ functions in the /inst/include/ folder. I then added the following statements to my Makevars and Makevars.win files:

PKG_CPPFLAGS =  -I../inst/include/

I then tried a test so in a file called test.cpp which I placed in /src , and which includes the following:

#include <shogun/lib/config.h>

and I get the error: test.cpp: fatal error: shogun/lib/config.h: No such file or directory compilation terminated.

What am I doing wrong?

You are trying to create a header only package out of a library that is not header only.

That is to say in the /inst/include/ you have a mixture of .h and .cpp . To rectify this, you should only retain the .h files in /inst/include/ . Keep a copy of the .h and .cpp together files in /src .

The best package to model your package after is RcppMLPACK1 with its use of inst/include/ , src/ , plugin manager definition , and linking plus cxx flags .

However, you might just want to create a package that links to system's libraries. eg RcppMLPACK2 . This package uses configure.ac , which is the master autoconf to generate configure to ensure the necessary paths are present. Note of extensions to autoconf in the m4 directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM