<div dir="ltr">Hi John,<div><br></div><div style>You should only need gfortran. llvm-gcc "should" work. If you don't have Apple's gcc, then you want the "other" gfortran from the developer website:</div>
<div style><br></div><div style><a href="http://r.research.att.com/gfortran-4.2.3.dmg">http://r.research.att.com/gfortran-4.2.3.dmg</a><br></div><div style><br></div><div style>The link seems to be down (at least I cannot access it, check with Simon Urbanek). That gfortran is fully independent. You may be able to find the binary from other repositories (including Python and Julia repos). I think this particular binary is used by a lot of folks across these languages.</div>
<div style><br></div><div style>I would not expect that installing gfortran would have any impact on the rest of your development. I have not seen any issues due to any library from the developer website. Simon is an excellent steward and I tend to blindly trust his judgment.</div>
<div style><br></div><div style>Best,</div><div style>Anirban</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 27, 2013 at 6:31 PM, John Swan <span dir="ltr"><<a href="mailto:johnswan@spamcop.net" target="_blank">johnswan@spamcop.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Anirban,<div><br></div><div>Thank you for your help. I believe you're right, I was coming to the same conclusion myself.</div>
<div><br></div><div>One thing however, I have Mountain Lion with Xcode 4.6 installed for iOS development. As far as I understand it, gcc 4.2 is not included with that version of Xcode.</div><div><br></div><div>Don't I have to install <a href="http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg" target="_blank">gcc-42-5666.3-darwin11.pkg</a> to get gcc 4.2 and gfortran? <a href="http://r.research.att.com/tools/" target="_blank">http://r.research.att.com/tools/</a> states that <a href="http://r.research.att.com/gfortran-lion-5666-3.pkg" target="_blank">gfortran-lion-5666-3.pkg</a> is for those who already have gcc 4.2 installed, but you seem to have it working ? </div>
<div><br></div><div>Additionally, can you tell me if installing these packages has any adverse effect on your Xcode development environment (llvm-clang, iOS development etc)?</div><div><br></div><div>Best regards</div><div>
John</div><div><br><div><div>On 27 Jun 2013, at 04:20, Anirban Mukherjee <<a href="mailto:anirban.mukherjee@gmail.com" target="_blank">anirban.mukherjee@gmail.com</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr">
inline + RcppArmadillo work on Mac. I tested the code in a Mac (Mountain Lion 10.8.4) before posting. Install gfortran from: <a href="http://r.research.att.com/gfortran-lion-5666-3.pkg" target="_blank">http://r.research.att.com/gfortran-lion-5666-3.pkg</a>. You can look here for more information: <a href="http://r.research.att.com/tools/" target="_blank">http://r.research.att.com/tools/</a>. If that does not work, post in R-SIG-Mac.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 26, 2013 at 7:04 PM, Anirban Mukherjee <span dir="ltr"><<a href="mailto:anirban.mukherjee@gmail.com" target="_blank">anirban.mukherjee@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p>library(inline); library(RcppArmadillo)<br></p><p>rowSumsRA <- cxxfunction(signature(x = "numeric"), plugin="RcppArmadillo", body='return Rcpp::wrap(arma::sum(<span>as<arma::mat></span>(x),0));')</p>
<p>colSumsRA <- cxxfunction(signature(x = "numeric"), plugin="RcppArmadillo", body='return Rcpp::wrap(arma::sum(<span>as<arma::mat></span>(x),1));')</p><p>Anirban</p>
<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Date: Wed, 26 Jun 2013 11:11:04 +0200<br>
From: John Swan <<a href="mailto:johnswan@spamcop.net" target="_blank">johnswan@spamcop.net</a>><br>
To: <a href="mailto:rcpp-devel@lists.r-forge.r-project.org" target="_blank">rcpp-devel@lists.r-forge.r-project.org</a><br>
Subject: [Rcpp-devel] Seamless Rcpp gives errors with RcppArmadillo<br>
Message-ID: <<a href="mailto:99384497-D7C4-4BC6-859E-C3FA1AB5FF7D@spamcop.net" target="_blank">99384497-D7C4-4BC6-859E-C3FA1AB5FF7D@spamcop.net</a>><br>
Content-Type: text/plain; charset="windows-1252"<br>
<br>
Hi,<br>
<br>
I just purchased Dirk's book on Seamless Rcpp and I'm finding it very useful.<br>
<br>
However, I'm having a strange error running RcppArmadillo inline, where the book examples seem to manage it effortlessly.<br>
I've been stuck on this for hours. Any help is most appreciated.<br>
<br>
I am using R 3.0 on Mac OS X Mountain Lion 10.8.4, sessionInfo output:<br>
> sessionInfo()<br>
R version 3.0.1 (2013-05-16)<br>
Platform: x86_64-apple-darwin10.8.0 (64-bit)<br>
<br>
locale:<br>
[1] en_GB.UTF-8/C/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8<br>
<br>
attached base packages:<br>
[1] stats graphics grDevices utils datasets methods base<br>
<br>
other attached packages:<br>
[1] inline_0.3.12 RcppArmadillo_0.3.900.0 Rcpp_0.10.3 BDgraph_2.6 huge_1.2.4 MASS_7.3-26 igraph_0.6.5-2<br>
[8] Matrix_1.0-12 lattice_0.20-15<br>
<br>
loaded via a namespace (and not attached):<br>
[1] grid_3.0.1 tools_3.0.1<br>
<br>
<br>
I have the following in a source file (somefile.R):<br>
library(Rcpp)<br>
library(inline)<br>
library(RcppArmadillo)<br>
<br>
rowSumsRcppArmadilloFunction <- '<br>
arma::rowvec rowSumsRcppArmadillo(NumericMatrix x){<br>
arma::mat X = arma::mat(x.begin(), x.nrow(), x.ncol(), false);<br>
return arma::sum(X, 1);<br>
}'<br>
<br>
rowSumsRcppArmadillo <- cxxfunction(signature(),<br>
plugin="Rcpp",<br>
incl=rowSumsRcppArmadilloFunction,<br>
body='<br>
return Rcpp::wrap(rowSumsRcppArmadillo());<br>
')<br>
<br>
<br>
If I try to execute this in R console with the source command, I get:<br>
<br>
> source("/Users/me/Desktop/R/somefile.R")<br>
file29967eb06d23.cpp:20: error: ?arma? has not been declared<br>
file29967eb06d23.cpp:20: error: expected constructor, destructor, or type conversion before ?rowSumsRcppArmadillo?<br>
file29967eb06d23.cpp: In function ?SEXPREC* file29967eb06d23()?:<br>
file29967eb06d23.cpp:35: error: ?rowSumsRcppArmadillo? was not declared in this scope<br>
make: *** [file29967eb06d23.o] Error 1<br>
<br>
ERROR(s) during compilation: source code errors or compiler configuration errors!<br>
<br>
Program source:<br>
1:<br>
2: // includes from the plugin<br>
3:<br>
4: #include <Rcpp.h><br>
5:<br>
6:<br>
7: #ifndef BEGIN_RCPP<br>
8: #define BEGIN_RCPP<br>
9: #endif<br>
10:<br>
11: #ifndef END_RCPP<br>
12: #define END_RCPP<br>
13: #endif<br>
14:<br>
15: using namespace Rcpp;<br>
16:<br>
17:<br>
18: // user includes<br>
19:<br>
20: arma::rowvec rowSumsRcppArmadillo(NumericMatrix x){<br>
21: arma::mat X = arma::mat(x.begin(), x.nrow(), x.ncol(), false);<br>
22: return arma::sum(X, 1);<br>
23: }<br>
24:<br>
25: // declarations<br>
26: extern "C" {<br>
27: SEXP file29967eb06d23( ) ;<br>
28: }<br>
29:<br>
30: // definition<br>
31:<br>
32: SEXP file29967eb06d23( ){<br>
33: BEGIN_RCPP<br>
34:<br>
35: return Rcpp::wrap(rowSumsRcppArmadillo());<br>
36:<br>
37: END_RCPP<br>
38: }<br>
39:<br>
40:<br>
Error in compileCode(f, code, language = language, verbose = verbose) :<br>
Compilation ERROR, function(s)/method(s) not created! file29967eb06d23.cpp:20: error: ?arma? has not been declared<br>
file29967eb06d23.cpp:20: error: expected constructor, destructor, or type conversion before ?rowSumsRcppArmadillo?<br>
file29967eb06d23.cpp: In function ?SEXPREC* file29967eb06d23()?:<br>
file29967eb06d23.cpp:35: error: ?rowSumsRcppArmadillo? was not declared in this scope<br>
make: *** [file29967eb06d23.o] Error 1<br>
In addition: Warning message:<br>
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file29967eb06d23.cpp 2> file29967eb06d23.cpp.err.txt' had status 1<br>
<br>
I added these:<br>
20: #include <RcppArmadillo.h><br>
21: // [[Rcpp::depends(RcppArmadillo)]]<br>
22:<br>
23: // [[Rcpp::export]]<br>
24:<br>
25: arma::rowvec rowSumsRcppArmadillo(NumericMatrix x){<br>
26: arma::mat X = arma::mat(x.begin(), x.nrow(), x.ncol(), false);<br>
27: return arma::sum(X, 1);<br>
28: }<br>
<br>
But then I just get this error:<br>
Error in compileCode(f, code, language = language, verbose = verbose) :<br>
Compilation ERROR, function(s)/method(s) not created! file77e03dcff275.cpp:20:27: error: RcppArmadillo.h: No such file or directory<br>
file77e03dcff275.cpp:25: error: ?arma? has not been declared<br>
file77e03dcff275.cpp:25: error: expected constructor, destructor, or type conversion before ?rowSumsRcppArmadillo?<br>
file77e03dcff275.cpp: In function ?SEXPREC* file77e03dcff275()?:<br>
file77e03dcff275.cpp:40: error: ?rowSumsRcppArmadillo? was not declared in this scope<br>
make: *** [file77e03dcff275.o] Error 1<br>
In addition: Warning message:<br>
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file77e03dcff275.cpp 2> file77e03dcff275.cpp.err.txt' had status 1<br>
<br>
<br>
<br>
So, I thought I'd try compilng it as a package, but when I try to call the package in R, I get errors like:<br>
Error in sourceCpp("./R/somefile.R") :<br>
Error 1 occurred building shared library.<br>
<br>
WARNING: The tools required to build C++ code for R were not found.<br>
<br>
Please install Command Line Tools for XCode (or equivalent).<br>
<br>
ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64'<br>
ld: warning: directory not found for option '-L/usr/local/lib/x86_64'<br>
ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3'<br>
ld: library not found for -lgfortran<br>
collect2: ld returned 1 exit status<br>
make: *** [sourceCpp_13326.so] Error 1<br>
<br>
<br>
The XCode command line tools *are* installed - I'm an iOS developer so I always make sure that they are there:<br>
<br>
John-MBPR:BDGraphSource johnswan$ which llvm-g++<br>
/usr/bin/llvm-g++<br>
John-MBPR:BDGraphSource johnswan$ llvm-g++ --version<br>
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)<br>
Copyright (C) 2007 Free Software Foundation, Inc.<br>
This is free software; see the source for copying conditions. There is NO<br>
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br>
<br>
<br>
Can anyone help?<br>
<br>
Thanks<br>
John<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130626/f34959cc/attachment-0001.html" target="_blank">http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130626/f34959cc/attachment-0001.html</a>><br>
<br>
------------------------------<br></blockquote></div></div></div>
</blockquote></div><br></div>
_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></blockquote>
</div><br></div></div></blockquote></div><br></div>