[R-pkg-devel] Problem building package depending on third party c++ source library.

Serguei Sokol @ergue|@@oko| @end|ng |rom gm@||@com
Wed Apr 30 15:31:37 CEST 2025


Le 29/04/2025 à 14:43, Nils Lüschow a écrit :
> Hello everybody,
> 
> as a new feature for the anticlust package (https://cran.r-project.org/ 
> web/packages/anticlust/index.html) we are trying to include a constraint 
> programming model, written in C++ utilizing the Gecode solver. While we 
> generally got this feature to work when Gecode is pre-installed on the 
> system, we would like to spare the users this step and include it with 
> the package (or inside a supplementary package) to install through the 
> regular R tooling. However, we run into a problem when it comes to 
> compiling Gecode during the packages build-process, which I describe in 
> this SO post:
> 
> https://stackoverflow.com/questions/79596214/configure-script-does-not- 
> generate-makefile-properly-for-3rd-party-library-used
> 
> I strongly suspect the Makevars file to be incorrect, if you want to 
> take a look or try to compile it yourself, I have uploaded the code of 
> the new feature as well as the source files of the Gecode library to 
> GitHub:
> 
> https://github.com/nilslueschow/Anticlust-Dispersion-Constraint-Model/ 
> tree/main/RcppTestPackage/src
I don't know if it is the source of your problem but it's safer to use 
CC and CXX variables provided by R building process (they are already 
predefined when you are in Makevars) which minimize the risks of 
incompatibility between R and your library. So instead of

cd $(GECODE_DIR) && $(MAKE)

I'd use something like

$(MAKE) -C $(GECODE_DIR) CC="$(CC)" CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)"

Best,
Serguei.

> 
> Thanks for your help!
> 
> Best,
> Nils Lüschow
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



More information about the R-package-devel mailing list