[Rcpp-devel] Rcpp build trouble with strings

Dirk Eddelbuettel edd at debian.org
Thu Aug 22 03:33:33 CEST 2013


Hi Jacob,

On 21 August 2013 at 19:53, jacob.a.russell.th at dartmouth.edu wrote:
| Thanks for the help! I ended up reading a little more and found that I
| could create a Makefile instead of using Makevars. I took this approach.

Do not do that.

R creates its own Makefile, and it is MUCH easier to cooperate with R than to
fight it.  See several posts by Simon Urbanek on the R lists for details.
We've been there too -- stick with src/Makevars.  At a minimum, you are
breaking multiarch builds and possibly more.

| I am including the Makefile in case anyone else has a similar problem to
| what I had but I don't recommend deviating from the Makevars approach
| unless you have to (it's nice that it will automatically compile all of
| the files for you). It's also nice that will automatically resolve the
| location of the R and Rcpp header and libs for you (architecture
| independent) and this will likely only work on some versions of linux.
| 
| PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e 'Rcpp:::LdFlags()') -L/usr/lib64/R/lib -lR
| PKG_CPPFLAGS= $(shell $(R_HOME)/bin/Rscript -e 'Rcpp:::CxxFlags()') -I. -I/usr/include/R -fPIC -g
| OBJECTS = analyze-linkage.o and.o api.o build-disjuncts.o command-line.o
| constituents.o count.o DG_commonTypes.o DGG_graphComponents.o
| DGG_heuristics.o DGG_strings.o DGG_templates.o DGG_tree.o DG_objectTable.o
| diGraph.o DLL_commonTypet s.o documentGraphGenerator.o error.o extract-links.o fast-match.o functions.o getDocGraph.o idiom.o linkset.o massage.o my_std.o parse.o post-process.o pp_knowledge.o pp_lexer.o pp_linkset.o preparation.o print.o print-util.o prune.o read-dict.o resources.o skip_exp.o string-set.o stringTable.o tokenize.o utilities.o word-file.o
| OBJS = DG_commonTypes.o DG_objectTable.o diGraph.o getDocGraph.o
| LIBS = libAF.a libDGG.a libDLL.a liblink_4_1b.a libmy_std.a libSTR.a
| .PHONY: clean xlibs
| 
| CC = g++
| 
| SantosDartmouth.so: $(OBJS) xlibs
|         $(CC) -shared -Wl,-O1,--sort-common,--as-needed,-z,relro $(PKG_LIBS) $(PKG_CPPFLAGS) $(OBJECTS) -o SantosDartmouth.so
| 
| xlibs:
|         $(shell for i in *.a;do ar -x $i;done)

Can you just include the source file that had gone into the libraries and
have them rebuilt?

| %.o: %.cpp
|         $(CC) $(PKG_CPPFLAGS) $(PKG_LIBS) -c $< -o $@
| 
| clean:
|         rm SantosDartmouth.so *.o 
| 
| Thanks again for the help!

Try the same with src/Makevars. 

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list