Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking problem with (Rcpp)armadillo and Makevars #1

Closed
jchiquet opened this issue Jul 25, 2018 · 1 comment
Closed

Linking problem with (Rcpp)armadillo and Makevars #1

jchiquet opened this issue Jul 25, 2018 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@jchiquet
Copy link
Collaborator

I am trying to wrap the optim library of @kthor in R via an R package using Rcpp/RcppArmadillo. Indeed, optim relies on armadillo itself.

To do that, I put the headers of optim into inst/include/ and the cpp files into src/. Then I tried to link everything in the src/Makevars files, and the package installation (including compilation of optim) is fine (at least, the package can be installed). The Makevars can be found there :

https://github.com/jchiquet/optimLibR/blob/414015b08a5e316de17b1e0b5385718abd23da6a/src/Makevars#L1-L41

Then I tried to create two small Rcpp functions for two examples available in the original optim library, starting with the following lines

// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::plugins(cpp11)]]
#define USE_RCPP_ARMADILLO
#include "optim.hpp"

However, when I call the corresponding R functions, I get the following Armadillo errors in R which I do not have wheh running them in 'pure' C++ (I am pretty sure it is not a syntax problem, the Rcpp code and the original C++ code are hopefully identical, except for the headers).

> library(optimLibR)
> ackley_function()
error: arma::memory::acquire(): out of memory
> library(optimLibR)
> logit_optimLib()
error: Mat::init(): requested size is not compatible with column vector layout

If someone with experience in writing R packages including external librarieis can at least check that the flags and libs in the Makevars are correctly set for optim/armadillo requirements, it would help a lot.

Thanks for your time

@jchiquet jchiquet added the help wanted Extra attention is needed label Jul 25, 2018
@jchiquet
Copy link
Collaborator Author

jchiquet commented Aug 3, 2018

Solved thanks to @kthohr kthohr/optim#2

@jchiquet jchiquet closed this as completed Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant