I want to use the cpp functions of an R-package (AlgDesign - https://github.com/jvbraun/AlgDesign/tree/master/src) within my own cpp project.
My usual IDE is Visual Studio 2015. I have found this related post Building R packages (C API) with Visual Studio (and How do I compile a dll with R and RCPP?) So I installed MinGW and CodeBlocks IDE on my Windows 8.1 and retry. I added the "Rdir/include" path to the "Project build options->search directories->compiler" within CodeBlocks.
But I still get "undefined reference _GetRNGstate" which is equivalent to MSVC "unresolved external symbol _GetRNGstate". So i guess the issue is a missing lib like the original questioner already mentioned. But i could not figure out which one either. There is no .lib file in my R-install dir.
Furthermore is not my intend to use Rcpp or to build an own R-package, I just want to access the SEXP FederovOpt(..args) function within my own cpp-project´
Edit: Lets say i want to transfer the AlgDesign src file function by function into an empty project. At some point I'll reach this:
#include "wheeler.h"
#include <string.h>
#include <stdlib.h>
#include <Rinternals.h>
#include <Rdefines.h>
#include <R.h>
#include <Rmath.h>
#include <R_ext/RS.h>
#include <R_ext/Utils.h>
/* Permute **********************************************************
| Randomly pemutes the n integers in a[] using the Fike
| algorithm. See Fike, "A permutation generation method" The Computer
| Journal, 18-1, Feb 75, 21-22.
*/
void Permute(
int *a,
int n
)
{
int i,
j,
temp;
GetRNGstate();
for (i = 1; i < n; i++) {
j = (int)((double)(1 + i)*unif_rand());
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
PutRNGstate();
}
int main(){
return 0;
}
I'll get 3 unresolved externals
void GetRNGstate(void)
defined in Random.h of R C API
void PutRNGstate(void)
defined in Random.h of R C API
double unif_rand(void)
defined in Random.h of R C API
Finally, i found this post: https://www.codeproject.com/Questions/1192515/I-want-to-run-R-script-from-Cplusplus-code
So of course, i am searching for a .lib file. But this file does not exist in Windows, i have to create the .lib file on my own. But i dont know how. I have found this, but it is very old and directories are completly different: https://uploads.cosx.org/2009/12/Integrate-R-into-C.pdf
Could you please help me? A simple "easy peasy use a makefile" or single cmd command wont help me, i cannot understand that. I never worked with makefiles before and i never build a .lib before.