<p><br>
On Jun 6, 2011 4:17 AM, &quot;baptiste auguie&quot; &lt;<a href="mailto:baptiste.auguie@googlemail.com" target="_blank">baptiste.auguie@googlemail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Thank you for the explanations below.<br>
&gt;<br>
&gt; On 5 June 2011 10:40, Dirk Eddelbuettel &lt;<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; On 5 June 2011 at 10:12, baptiste auguie wrote:<br>
&gt; &gt; | Hi Dirk and all,<br>
&gt; &gt; |<br>
&gt; &gt; | On 4 June 2011 12:04, Dirk Eddelbuettel &lt;<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>&gt; wrote:<br>
&gt; &gt; | &gt;<br>
&gt; &gt; | &gt; Baptiste,<br>
&gt; &gt; | &gt;<br>
&gt; &gt; | &gt; On 4 June 2011 at 11:45, baptiste auguie wrote:<br>
&gt; &gt; | &gt; | Dear list,<br>
&gt; &gt; | &gt; |<br>
&gt; &gt; | &gt; | My package cda, which I was hoping to release on CRAN, fails to<br>
&gt; &gt; | &gt; | compile on R-forge with error,<br>
&gt; &gt; | &gt; |<br>
&gt; &gt; | &gt; | ** testing if installed package can be loaded<br>
&gt; &gt; | &gt; | Error in dyn.load(file, DLLpath = DLLpath, ...) :<br>
&gt; &gt; | &gt; |   unable to load shared object &#39;/tmp/RtmpbztUMm/Rinst1829c04c/cda/libs/cda.so&#39;:<br>
&gt; &gt; | &gt; |   /tmp/RtmpbztUMm/Rinst1829c04c/cda/libs/cda.so: undefined symbol: zgetri_<br>
&gt; &gt; | &gt; |<br>
&gt; &gt; | &gt; | It builds fine on my local machines (Mac OS 10.5, 10.6).<br>
&gt; &gt; | &gt; |<br>
&gt; &gt; | &gt; | &gt;From an older discussion on this list &lt;<br>
&gt; &gt; | &gt; | <a href="http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg00678.html" target="_blank">http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg00678.html</a>&gt;<br>
&gt; &gt; | &gt; | the issue seems to be that Armadillo&#39;s inv() relies on a function that<br>
&gt; &gt; | &gt; | is not provided by R, only by LAPACK. I have just replaced inv() by<br>
&gt; &gt; | &gt; | pinv() and solve() in my code; merely to see what happens, but chances<br>
&gt; &gt; | &gt; | are they also require a full LAPACK.<br>
&gt; &gt; |<br>
&gt; &gt; | Indeed, the error on R-forge is now with zgels_, required to solve<br>
&gt; &gt; | linear systems. It seems one cannot solve Armadillo linear systems<br>
&gt; &gt; | without LAPACK in the current situation.<br>
&gt; &gt;<br>
&gt; &gt; Yes. Doug, Romain and myself should address that, or at least make it clear<br>
&gt; &gt; what feature of the full Armadillo are lacking in RcppArmadillo.<br>
&gt; &gt;<br>
&gt; &gt; | &gt; Sometime relatively early in the RcppArmadillo development process, Doug<br>
&gt; &gt; | &gt; convinced Romain and myself to go for a pure template solution with Armadillo<br>
&gt; &gt; | &gt; as all / most things found during the configure (or in this case, cmake)<br>
&gt; &gt; | &gt; stage can be assumed &#39;found&#39; given that we have around us by design.  So no<br>
&gt; &gt; | &gt; testing, no local library and full reliance and what R gives us.<br>
&gt; &gt; | &gt;<br>
&gt; &gt; | &gt; That was a brilliant idea, and has freed us from having to rely on building<br>
&gt; &gt; | &gt; and shipping a library, having to tell users how to set PKG_LIBS etc pp and I<br>
&gt; &gt; | &gt; firmly believe that this helped tremendously in getting RcppArmadillo more<br>
&gt; &gt; | &gt; widely used. So I would not want to revert this.<br>
&gt; &gt; |<br>
&gt; &gt; | It sounds like a good choice, I agree. Yet solving a linear system is<br>
&gt; &gt; | quite a crucial task in linear algebra; it would be nice if we could<br>
&gt; &gt; | come up with a tutorial recipe for dummies like me.<br>
&gt; &gt; |<br>
&gt; &gt; | &gt;<br>
&gt; &gt; | &gt; In any event, it seems that you need more LAPACK than R has for you.  That is<br>
&gt; &gt; | &gt; likely to be a dicey situation as you per se do not know whether R was built<br>
&gt; &gt; | &gt; and linked with its own (subset) copy of LAPACK, or whether it uses system<br>
&gt; &gt; | &gt; LAPACK libraries (as e.g. the Debian / Ubuntu systems do).  So you may be in<br>
&gt; &gt; | &gt; a spot bother and I not sure what I can recommend --- other than trying your<br>
&gt; &gt; | &gt; luck at some short configure snippets that will run at package build time to<br>
&gt; &gt; | &gt; determine whether the system you want to build cda on it &#39;rich&#39; enough to<br>
&gt; &gt; | &gt; support it.  I can help you off list with some configure snippets as some of<br>
&gt; &gt; | &gt; my packages have configure code; adding a test for zgetri should be feasible.<br>
&gt; &gt; | &gt;<br>
&gt; &gt; | &gt; | Does anybody have any experience<br>
&gt; &gt; | &gt; | dealing with such issues w.r.t releasing a package on R-forge / CRAN?<br>
&gt; &gt; | &gt; | Is there any chance they would consider installing LAPACK on those<br>
&gt; &gt; | &gt; | servers, or is there no point in asking such things?<br>
&gt; &gt; | &gt;<br>
&gt; &gt; | &gt; I don&#39;t think it is a matter of fixing the R-Forge server. I think it is a<br>
&gt; &gt; | &gt; matter of making your package installable on the largest number of user<br>
&gt; &gt; | &gt; systems.  Also try <a href="http://win-builder.r-project.org" target="_blank">win-builder.r-project.org</a> to see how it fares on that<br>
&gt; &gt; | &gt; platform.<br>
&gt;<br>
&gt; Unsurprisingly, it fails, with the same complaint as R-forge.<br>
&gt;<br>
&gt; &gt; |<br>
&gt; &gt; | I was under the impression that R-forge or CRAN, if it had LAPACK<br>
&gt; &gt; | installed, could produce binaries for the relevant platforms, and<br>
&gt; &gt; | users would not have to build the package themselves and would not be<br>
&gt; &gt; | required of having LAPACK on their machine. That&#39;s probably a<br>
&gt; &gt; | misconception, isn&#39;t it?<br>
&gt; &gt;<br>
&gt; &gt; If and only statically linked binaries or libraries where produced, which is<br>
&gt; &gt; generally not the case. Many OSs (Linux incl) ship source only and otherwise<br>
&gt; &gt; link dynamically, others (Windoze) use dynamic linking and OS X is for all I<br>
&gt; &gt; know somewhere in the middle (as you can get prebuild packages with dynamic<br>
&gt; &gt; linking or build from source).<br>
&gt;<br>
&gt; I see; so basically the user will always need to have a full LAPACK<br>
&gt; installed. Here&#39;s one question then, if R-core didn&#39;t consider<br>
&gt; necessary to include those particular functions from LAPACK,<br>
&gt; presumably that means that R defines its own routines to solve linear<br>
&gt; systems and invert matrices. Is there any possibility to use those<br>
&gt; routines with Armadillo?<br><br></p><p>One important point has been missed in this discussion, which is that the particular Lapack subroutine that is not found in the subset of Lapack shipped with R is for general, complex-valued matrices (just google the name zgetri).  The way that Armadillo is structured it is either all-in or all-out with respect to complex-valued matrices  If you allow for complex matrices then you must have all the supporting subroutines for whatever you are calling.  If you call inv() you need to allow for all the [sdcz]getri routines to be available.</p>
<p>So one possibility is to check the Armadillo sources to see if you can suppress the use of complex-valued matrices when compiling your package.  A quick glance indicates that this might now be easy.</p><p>Otherwise, remember the first rule of numerical linear algebra which is, &quot;If your algorithm involves computing the inverse of a matrix you should rethink the algorithm because there is a better way of doing it&quot;.  So why do you need inv()?  If the answer is to solve a linear system of equations then you use solve(), you do not use inv().  If, for some truly unusual reason you actually need the inverse (and, remember in 99.99% of the cases where people think they need the inverse, they don&#39;t) then you use a combination of solve() and eye().</p>
<p>&gt; &gt; | Sorry for being dense, I don&#39;t know anything about linking R to</p><p>
&gt; &gt; | external dependencies.<br>
&gt; &gt;<br>
&gt; &gt; It can be done; there are many examples -- for example every package using<br>
&gt; &gt; the GSL.<br>
&gt;<br>
&gt; I just checked how RcppGSL does it, and well, this configure magic is<br>
&gt; way above my head.<br>
&gt;<br>
&gt; Best,<br>
&gt;<br>
&gt; baptiste<br>
&gt; _______________________________________________<br>
&gt; Rcpp-devel mailing list<br>
&gt; <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
&gt; <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><br>
</p>