g ++ ld找不到用于x86_64体系结构的RInside符号 [英] g++ ld can't find RInside symbols for x86_64 architecture

查看:302
本文介绍了g ++ ld找不到用于x86_64体系结构的RInside符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个链接器错误,说当我尝试使用g ++编译RInside示例文件时,无法找到符号。任何帮助将不胜感激。

I get a linker error saying that symbol(s) cannot be found when I try to compile an RInside sample file with g++. Any assistance would be appreciated.

R版本2.13.1安装在Mac OS X 10.5上。 Rcpp和RInside包含文件已经复制到usr / include目录。 R头文件和库已经使用g ++的-I和-L修饰符包含,如下所示:

R version 2.13.1 is installed on Mac OS X 10.5. Rcpp and RInside include files have been copied to the usr/include directory. R headers and libraries have been included using the -I and -L modifiers of g++ as shown:

$g++ -I/Library/Frameworks/R.framework/Headers -L/Library/Frameworks/R.framework/Libraries rinside_sample0.cpp 

rinside_sample0.cpp文件是RInside软件包提供的示例,如下所示:

The rinside_sample0.cpp file is a sample provided with the RInside package, shown below:

// -*- 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 ++编译时,得到一个错误,如下所示: / p>

When I attempt to compile with g++ I get an error, shown below:

ld: symbol(s) not found for architecture x86_64

有人可以告诉我我做错了什么以及如何解决它?

Can someone tell me what I'm doing wrong and how to fix it? Any assistance would be appreciated.

推荐答案

您使用的编译器(似乎64位)和库之间有一个不匹配显然是32位),这使得链路尝试失败。最简单的解决方案是从源重新安装Rcpp和RInside;它将为编译器重新创建文件(大概是64位)。

You have a mismatch between the compiler used (seemingly 64-bit) and the library found (apparently 32-bit) which makes the link attempt fail. The easiest solution is probably to re-install both Rcpp and RInside from sources; that will recreate files for the compiler (presumably 64-bit).

正常构建能力的Proof由CRAN检查提供如在Windows检查中修补此补丁,您甚至可以自己上传到 win-builder

"Proof" of normal ability to build is provided by the CRAN checks as eg this R-patched on Windows check, and you could even upload to win-builder yourself.

rcpp-devel列表可以进一步帮助这一点,因为几个OS X用户正在阅读它。我似乎记得在OS X从源代码是建议的解决方案,但它是我的合作者谁在OS X上工作,而不是我:)

The rcpp-devel list can be of further assistance with this as several OS X users are reading it. I seem to recall that on OS X builds from source are the recommended solution but it is my coauthor who works on OS X not me :)

这篇关于g ++ ld找不到用于x86_64体系结构的RInside符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆