I am developing an R-binding for a Solar PV simulation library developed by NREL. I am able to successfully compile the R-extension RcppSSC that I wrote using Rcpp. I based this on some examples from Rcpp gallery and the book Seamless R and C++ Integration with Rcpp (Use R!) by Dirk Eddelbuettel.
The ssc library from NREL has x86 and x64 .lib and .dll files. When I build and test the module in RStudio, I get the following error. I check the load dependency and RcppSCC.dll needs ssc.dll.
I think I need to modify the Makevars file to copy the ssc.lib and ssc.dll files to the appropriate location during the build. How do I do this?
Any guidance or help is greatly appreciated. I'm very comfortable with C, C++, Make etc. No experience developing R extensions or Rcpp based modules.
I ran into some issues during linking and I fixed that easily.
My Makevars.win is as follows.
PKG_CPPFLAGS += -I. -I"C:/SAM/ssc-sdk-2014-1-21"
ifeq "$(WIN)" "64"
PKG_LIBS += -L"C:/SAM/ssc-sdk-2014-1-21/win64/" -lssc
else
PKG_LIBS += -L"C:/SAM/ssc-sdk-2014-1-21/win32/" -lssc
endif
=============================RStudio error message====================================
==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source RcppSSC
* installing to library 'C:/Users/kumar_000/Documents/R/win-library/3.1'
* installing *source* package 'RcppSSC' ...
** libs
g++ -m64 -I"C:/PROGRA~1/R/R-31~1.1/include" -DNDEBUG -I. -I"C:/SAM/ssc-sdk-2014-1-21" -I"C:/Users/kumar_000/Documents/R/win-library/3.1/Rcpp/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
g++ -m64 -I"C:/PROGRA~1/R/R-31~1.1/include" -DNDEBUG -I. -I"C:/SAM/ssc-sdk-2014-1-21" -I"C:/Users/kumar_000/Documents/R/win-library/3.1/Rcpp/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c RcppSSC.cpp -o RcppSSC.o
g++ -m64 -shared -s -static-libgcc -o RcppSSC.dll tmp.def RcppExports.o RcppSSC.o -LC:/SAM/ssc-sdk-2014-1-21/win64/ -lssc -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-31~1.1/bin/x64 -lR
installing to C:/Users/kumar_000/Documents/R/win-library/3.1/RcppSSC/libs/x64
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Users/kumar_000/Documents/R/win-library/3.1/RcppSSC/libs/x64/RcppSSC.dll':
LoadLibrary failure: The specified module could not be found.
Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Users/kumar_000/Documents/R/win-library/3.1/RcppSSC'
Exited with status 1.