问题
environment:
- OS:Windows10 [10.0.14393]
- R:3.4.1 (2017-06-30) -- "Single Candle" 32-bit
- Rstudio:1.0.143
- Rtools:3.4.0.1964
This is my first time to build R package (named testt
).
I'm trying to build a package with some C code without using Rcpp
.
I have put all .c files (called lca.c
, rlca_cond.c
, rlca_prev.c
and rlca_condprev.c
)
and their header file in /src
.
And I have some C function defined in chanmat.c
, declared in chanmat.h
.chanmat.c
and chanmat.h
are also in /src
.
Both lca.h
, rlca_cond.h
, rlca_prev.h
and rlca_condprev.h
have #include 'chanmat.h'
.
In chanmat.h
, I use the following to prevent multiple definition when compiling.
#ifndef CHANMATH_H
#define CHANMATH_H
...
#endif
I have also used following in NAMESPACE file (generated by roxygen2
)
useDynLib(testt,lca)
useDynLib(testt,rlca_cond)
useDynLib(testt,rlca_prev)
useDynLib(testt,rlca_condprev)
useDynLib(testt,chanmat)
When I run build & reload, I got following error
Updating testt documentation
Loading testt
Error in FUN(X[[i]], ...) :
no such symbol chanmat in package
C:/Users/elephant/Desktop/project/testt/src/testt.dll
Calls: suppressPackageStartupMessages ... assignNativeRoutines ->
getNativeSymbolInfo -> lapply -> FUN
��������
Exited with status 1.
I have no idea why chanmat.c
/chanmat.h
are failed to compile.
This question bothers me for a long time.
Any thoughts on how to fix this?
来源:https://stackoverflow.com/questions/45541684/build-r-package-with-c-code-without-rcpp