【发布时间】:2013-06-29 08:55:57
【问题描述】:
我使用 R 版本 2.15.3。我想要在我的 C++ 程序库 Rcpp.h 中。如何告诉编译器库在哪里?我使用实用工具:
CC=g++
LDFLAGS=$(shell Rscript -e "Rcpp:::LdFlags()")
CFLAGS=$(shell Rscript -e "Rcpp:::CxxFlags()")
SOURCES=src/main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
myrcpp : $(OBJECTS)
$(CC) $(OBJECTS) myrcpp
main.o : $(SOURCES)
$(CC) -o $(LDFLAGS) $(CFLAGS) $(SOURCES)
clean :
rm myrcpp $(OBJECTS)
但我有错误,编译器找不到 Rcpp.h
【问题讨论】:
-
shell Rscript -e "Rcpp:::LdFlags()"和shell Rscript -e "Rcpp:::CxxFlags()"实际产生了什么?那应该给出一个-I<something that contains Rcpp.h(很可能还有其他一些东西)。 -
shell Rscript -e "Rcpp:::LdFlags()" 应该给出:-L/usr/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr /lib/R/site-library/Rcpp/lib 和 shell Rscript -e "Rcpp:::CxxFlags()": -I/usr/lib/R/site-library/Rcpp/include