当我尝试使用 g++ 编译 RInside 示例文件时,出现链接器错误,指出无法找到符号。如有任何帮助,我们将不胜感激。
R 版本 2.13.1 安装在 Mac OS X 10.5 上。 Rcpp 和 RInside 包含文件已复制到 usr/include 目录。已使用 g++ 的 -I 和 -L 修饰符包含 R header 和库,如下所示:
$g++ -I/Library/Frameworks/R.framework/Headers -L/Library/Frameworks/R.framework/Libraries rinside_sample0.cpp
rinside_sample0.cpp 文件是 RInside 包中提供的示例,如下所示:
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// Simple example showing how to do the standard 'hello, world' using embedded R
//
// Copyright (C) 2009 Dirk Eddelbuettel
// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
//
// GPL'ed
#include <RInside.h> // for the embedded R via RInside
int main(int argc, char *argv[]) {
RInside R(argc, argv); // create an embedded R instance
R["txt"] = "Hello, world!\n"; // assign a char* (string) to 'txt'
R.parseEvalQ("cat(txt)"); // eval the init string, ignoring any returns
exit(0);
}
当我尝试使用 g++ 编译时出现错误,如下所示:
ld: symbol(s) not found for architecture x86_64
有人可以告诉我我做错了什么以及如何解决吗?如有任何帮助,我们将不胜感激。
最佳答案
我知道这是一个非常古老的问题,但我添加这个以防它对其他人有帮助。
我花了好几个小时研究这个。我有一个 Mac 操作系统(Mountain Lion 10.7)。
我下载了 RInside,转到示例并输入 make
,但一直收到此 ld
错误。
新安装的 xcode,gcc as mentioned in this thread许多其他尝试都没有帮助。
我已经使用 RStudio 安装了 Rcpp。
但是以下对我有用。 从我的 Mac 终端,我重新安装了 Rcpp 和 RInside,正如 Dirk 在上面建议的那样,使用:
R CMD INSTALL ./Downloads/Rcpp_0.10.3.tar.gz
R CMD INSTALL ./Downloads/RInside_0.2.10.tar.gz
现在,当我转到示例目录并键入 make
时,它运行得很顺利。
希望这对使用 OS X 的人有帮助,他们来看这个问题。
关于c++ - g++ ld 找不到 x86_64 架构的 RInside 符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6880771/