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 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
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);
}
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.
I know this is a very old question, but I am adding this in case it helps someone else.
I spent hours and hours looking into this. I have a Mac OS (Mountain Lion 10.7).
I downloaded RInside, went over to examples and typed make
but kept getting this ld
error.
New installs of xcode, gcc as mentioned in this thread and numerous other attempts didn't help.
I already had Rcpp installed using RStudio.
However the following worked for me.
From my Mac Terminal I re-installed Rcpp and RInside as Dirk suggests above using:
R CMD INSTALL ./Downloads/Rcpp_0.10.3.tar.gz
R CMD INSTALL ./Downloads/RInside_0.2.10.tar.gz
Now, when I went to the examples directory and typed make
, it worked without a hitch.
Hope this helps someone using OS X, who comes looking at this question.
Usually has to do with Linking libs that are not suited for build target Architecture. Check the framework settings to see architecture it is built for (i386 is more common than x86_64). This also might mean that lib isn't built for both 32/64 bits. Might consider recompiling it if you have access to the sources.
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" 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.
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 :)