【问题标题】:Integration R and C++集成 R 和 C++
【发布时间】: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

标签: c++ ubuntu makefile rcpp


【解决方案1】:

Rcpp 用于在 R 中嵌入 C++ 代码。如果这是您想要做的,您可以通过阅读包中的文档来了解如何制作使用 Rcpp 的 R 包。

如果您想要创建一个使用Rcpp 的C++ 应用程序,您需要查看RInside 及其许多文档化示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-25
    • 2012-03-23
    • 2010-11-12
    • 1970-01-01
    相关资源
    最近更新 更多