[Rcpp-devel] Issues creating static library using Makevars
Akhila Chowdary Kolla
akhilakollasrinu424jf at gmail.com
Sat Jun 27 00:55:46 CEST 2020
Hello Everyone,
I am trying to generate a C static library(libdeepstate.a) in an
Rcpp(inst/include/lib) package using Makevars similar to RInside(generating
RInside.so and RInside.a)
My static library libdeepstate.a has four compiled c programs
[image: image.png]
I saved those files DeepState.c, Log.c,Option.c,Stream.c in inst/include
folder and using src/Makevars to compile those *.c files and link the
respective object files with the static library as follows:
src/Makevars:
USERLIBST=libdeepstate.a
USERDIR=../inst/lib
PKG_CPPFLAGS =-I. -I../inst/include/
PKG_LIBS =
all: $(SHLIB) userLibrary
SOURCES= ../inst/include/DeepState.c ../inst/include/Log.c
../inst/include/Option.c ../inst/include/Stream.c
OBJECTS= $(SOURCES:.c=.o)
userLibrary: $(USERLIBST)
- at if test ! -e $(USERDIR)$(R_ARCH); then mkdir -p $(USERDIR)$(R_ARCH); fi
cp $(USERLIBST) $(USERDIR)$(R_ARCH)
rm $(USERLIBST)
*$(USERLIBST): $(OBJECTS)$(AR) qc $(USERLIBST) $^*
@if test -n "$(RANLIB)"; then $(RANLIB) $(USERLIBST); fi
When I install the package I get something like this :
*gcc -I"/home/akhila/lib/R/include" -DNDEBUG -I. -I../inst/include/
-I/usr/local/include -fpic -g -O2 -c ../inst/include/DeepState.c -o
../inst/include/DeepState.ogcc -I"/home/akhila/lib/R/include" -DNDEBUG -I.
-I../inst/include/ -I/usr/local/include -fpic -g -O2 -c
../inst/include/Log.c -o ../inst/include/Log.ogcc
-I"/home/akhila/lib/R/include" -DNDEBUG -I. -I../inst/include/
-I/usr/local/include -fpic -g -O2 -c ../inst/include/Option.c -o
../inst/include/Option.ogcc -I"/home/akhila/lib/R/include" -DNDEBUG -I.
-I../inst/include/ -I/usr/local/include -fpic -g -O2 -c
../inst/include/Stream.c -o ../inst/include/Stream.ogcc -shared
-L/home/akhila/lib/R/lib -L/usr/local/lib -o testproject.so
../inst/include/DeepState.o ../inst/include/Log.o ../inst/include/Option.o
../inst/include/Stream.o -L/home/akhila/lib/R/lib -lRar qc libdeepstate.a
../inst/include/DeepState.o ../inst/include/Log.o ../inst/include/Option.o
../inst/include/Stream.ocp libdeepstate.a ../inst/lib*
*rm libdeepstate.a*
The code can be found in GitHub:https://github.com/akhikolla/RcppDeepState/
This Travis build has the complete details of the warnings:
https://travis-ci.org/github/akhikolla/RcppDeepState/builds/702470420
But when I check the package I get the following warnings: using
devtools::check()
*W checking pragmas in C/C++ headers and code ... WARNING*
* File which contains non-portable pragma(s) ‘inst/include/Log.c’
File which contains pragma(s) suppressing diagnostics:
‘inst/include/Log.c’✓ checking compilation flags used ...W checking
compiled code ... File ‘testproject/libs/testproject.so’: Found
‘__assert_fail’, possibly from ‘assert’ (C) Object:
‘../inst/include/DeepState.o’ Found ‘__printf_chk’, possibly from
‘printf’ (C) Objects: ‘../inst/include/DeepState.o’,
‘../inst/include/Log.o’ Found ‘abort’, possibly from ‘abort’ (C)
Object: ‘../inst/include/DeepState.o’ Found ‘exit’, possibly from
‘exit’ (C) Objects: ‘../inst/include/DeepState.o’,
‘../inst/include/Option.o’ Found ‘printf’, possibly from ‘printf’ (C)
Object: ‘../inst/include/Log.o’ Found ‘puts’, possibly from
‘printf’ (C), ‘puts’ (C) Objects: ‘../inst/include/DeepState.o’,
‘../inst/include/Log.o’ Found ‘rand’, possibly from ‘rand’ (C)
Object: ‘../inst/include/DeepState.o’ Found ‘srand’, possibly from
‘srand’ (C) Object: ‘../inst/include/DeepState.o’ Found ‘stderr’,
possibly from ‘stderr’ (C) Object: ‘../inst/include/Log.o’ Found
‘stdout’, possibly from ‘stdout’ (C) Object: ‘../inst/include/Log.o’
Found ‘vprintf’, possibly from ‘vprintf’ (C) Object:
‘../inst/include/Log.o’ File ‘testproject/libs/testproject.so’: Found
no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’ Compiled code
should not call entry points which might terminate R nor write to
stdout/stderr instead of to the console, nor use Fortran I/O nor system
RNGs. It is good practice to register native routines and to disable
symbol search.*
*Found no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’ - why is
this necessary as I am trying to compile some external C
files(inst/include/DeepState.c) which are not in src folder*
*Compiled code should not call entry points which might terminate R
nor write to stdout/stderr instead of to the console, nor use Fortran
I/O nor system RNGs. - what does this mean?*
how can I solve this issue and get rid of the warning in the R CMD check?
Can someone please suggest a way to resolve this?
Regards,
Akhila Chowdary Kolla
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20200626/85505235/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 19482 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20200626/85505235/attachment-0001.png>
More information about the Rcpp-devel
mailing list