[Rcpp-devel] qtdensity example build problem

Dirk Eddelbuettel edd at debian.org
Mon May 7 16:15:17 CEST 2012


Jarny,

(Is your Reply-To: different on purpose?)

On 7 May 2012 at 23:26, Jarny Choi wrote:
| I'm trying to build the qtdensity example which comes with RInside, using Qt
| Creator and the qtdensity.pro file included, but my build fails because g++
| can't find libRInside.a. Running Rscript on command line shows that
| RInside:::LdFlags() does not return the full path, as it is doing for Rcpp,
| hence the error:
| 
| > /Library/Frameworks/R.framework/Resources/bin/Rscript -e "Rcpp:::CxxFlags()"
| -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include
| 
| > /Library/Frameworks/R.framework/Resources/bin/Rscript -e "Rcpp:::LdFlags()"
| /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/lib/x86_64
| /libRcpp.a
| 
| > /Library/Frameworks/R.framework/Resources/bin/Rscript -e "RInside:::CxxFlags
| ()"
| -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/
| include
| 
| > /Library/Frameworks/R.framework/Resources/bin/Rscript -e "RInside:::LdFlags()
| "
| /libRInside.a
| 
| (RInside 0.2.6, OS 10.6.8). Have I missed something obvious here? The only
| thing I can think of is that it's an architecture issue, as there is no .../
| RInside/lib/x86_64/libRInside.a file.

That could very well be a bug on OS X.  As I do not have an OS X box, I can't
test this.  So could you poke around locally?  

The code looks pretty innocent:

## Use R's internal knowledge of path settings to find the lib/ directory
## plus optinally an arch-specific directory on system building multi-arch
RInsideLdPath <- function() {
    if (nzchar(.Platform$r_arch)) {     ## eg amd64, ia64, mips
        system.file("lib",.Platform$r_arch,package="RInside")
    } else {
        system.file("lib",package="RInside")
    }
}

What does that function return for you?  And what does .Platform$r_arch say?
Are we by chance in the 'true' branch of that if statement?   And on the
other hand, very similar code is used for Rcpp.

And that 'RInsideLdPath' function is used here to initialize rinsidedir:

## Provide linker flags -- i.e. -L/path/to/libRInside -- as well as an
## optional rpath call needed to tell the Linux dynamic linker about the
## location.  This is not needed on OS X where we encode this as library
## built time (see src/Makevars) or Windows where we use a static library
## Updated Jan 2010:  We now default to static linking but allow the use
##                    of rpath on Linux if static==FALSE has been chosen
##                    Note that this is probably being called from LdFlags()
RInsideLdFlags <- function(static=TRUE) {
    rinsidedir <- RInsideLdPath()
    if (static) {                               # static is default on Windows and OS X
        flags <- paste(rinsidedir, "/libRInside.a", sep="")
        if (.Platform$OS.type=="windows") {
            flags <- shQuote(flags)
        }
    } else {					# else for dynamic linking
        flags <- paste("-L", rinsidedir, " -lRInside", sep="") # baseline setting
        if ((.Platform$OS.type == "unix") &&    # on Linux, we can use rpath to encode path
            (length(grep("^linux",R.version$os)))) {
            flags <- paste(flags, " -Wl,-rpath,", rinsidedir, sep="")
        }
    }
    invisible(flags)
}


And that function is used by the one you called:


## LdFlags defaults to static linking on the non-Linux platforms Windows and OS X
LdFlags <- function(static=ifelse(length(grep("^linux",R.version$os))==0, TRUE, FALSE)) {
    cat(RInsideLdFlags(static=static))
}


Your help is appreciated.

Cheers, Dirk

| 
| Thanks.
| jc (Melbourne)
| 
| 
| 
| 
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- 
R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL
See agenda, registration details and more at http://www.RinFinance.com


More information about the Rcpp-devel mailing list