I use Windows 10 with R version 4.1.0. I wanted to create a package with Rcpp and RcppArmadillo codes in it. Now the Rcpp codes are compiling without errors and providing answers. But while compiling the package it starts weird problems.
I tried editing the NAMESPACE
useDynLib(sagnik, .registration = TRUE)
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp,sourceCpp,evalCpp))
Tried editing the Makevars.win
CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(shell $(R_HOME)/bin${R_ARCH_BIN}/Rscript.exe -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
and the Makevars
CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
But the following errors are still showing while using CLEAN & REBUILD
==> Rcpp::compileAttributes()
* Updated src/RcppExports.cpp
* Updated R/RcppExports.R
==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source hijibijibij
* installing to library 'C:/Users/sagni/Documents/R/win-library/4.1'
* installing *source* package 'SBHSdemo' ...
** using staged installation
** libs
/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-4.1.0/include" -DNDEBUG -I'C:/Users/sagni/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/sagni/Documents/R/win-library/4.1/RcppArmadillo/include' -fopenmp -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c FHSagnik.cpp -o FHSagnik.o
/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-4.1.0/include" -DNDEBUG -I'C:/Users/sagni/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/sagni/Documents/R/win-library/4.1/RcppArmadillo/include' -fopenmp -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
/mingw64/bin/g++ -shared -s -static-libgcc -o SBHSdemo.dll tmp.def FHSagnik.o RcppExports.o -LC:/PROGRA~1/R/R-4.1.0/bin/x64 -lRlapack -LC:/PROGRA~1/R/R-4.1.0/bin/x64 -lRblas -lgfortran -lm -lquadmath -LC:/PROGRA~1/R/R-4.1.0/bin/x64 -lR
C:/RBuildTools/4.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: FHSagnik.o:FHSagnik.cpp:(.text+0x2ff): undefined reference to `omp_get_num_threads'
C:/RBuildTools/4.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: FHSagnik.o:FHSagnik.cpp:(.text+0x306): undefined reference to `omp_get_thread_num'
C:/RBuildTools/4.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: FHSagnik.o:FHSagnik.cpp:(.text+0xd43): undefined reference to `omp_in_parallel'
C:/RBuildTools/4.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: FHSagnik.o:FHSagnik.cpp:(.text+0xd58): undefined reference to `omp_get_max_threads'
C:/RBuildTools/4.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: FHSagnik.o:FHSagnik.cpp:(.text+0xfa1): undefined reference to `GOMP_parallel'
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'SBHSdemo'
Can anyone give me any idea of what to do?