[R-SIG-Mac] Compiling problem:
Simon Urbanek
simon.urbanek at r-project.org
Tue Jul 13 00:58:33 CEST 2010
Conrad,
On Jul 12, 2010, at 4:57 PM, Conrad Stack wrote:
> On Sun, Jul 11, 2010 at 12:56 PM, Simon Urbanek <simon.urbanek at r-project.org
>> wrote:
>
>>
>> On Jul 10, 2010, at 4:55 PM, Conrad Stack wrote:
>>
>>> Hello fellows,
>>>
>>> I'm currently developing an R package and having some trouble getting it
>> to
>>> install on Mac OS (the build process works fine on Windows 7 and Ubuntu
>> 10).
>>> The little prototype that I'm trying to get working compiles a large
>> amount
>>> of C++ code which is connected to R via Rcpp (0.8.2). The C++ is
>> compiled
>>> using autoconfig scripts into a static library which is used in Makevars
>> (in
>>> the src directory). Here is the relevant Makevars line (where libBrownie
>> is
>>> the static library just compiled):
>>>
>>> PKG_LIBS=-s -L. -L./brownie_src -lBrownie -lR -lgsl -lgslcblas -lm
>>>> /opt/local/lib/R/library/Rcpp/lib/libRcpp.a
>>>
>>
>> That sounds like a lot of trouble in itself (you should not include any R
>> flags since that can break and -lR is not what's used on OS X; -s it bad as
>> well and static libraries are better linked using their name since they have
>> lower priority in -l). But it could be really anything including bugs in
>> your package, so without the actual package I fear we can't help you much.
>>
>>
> Thanks Simon, linking the static library using it's name directly and
> removing the -lR and -s flags fixed the bus error. Unfortunately, I'm now
> getting another error when the package tries to load:
>
> Error in dyn.load("RBrownie.so") :
>
> unable to load shared library
>> '/Users/conrad/brownie/RBrownie/src/RBrownie.so':
>
> dlopen(/Users/conrad/brownie/RBrownie/src/RBrownie.so, 6): Symbol not
>> found: __ZTV16NewickTreeWriter
>
> Referenced from: /Users/conrad/brownie/RBrownie/src/RBrownie.so
>
> Expected in: dynamic lookup
>
>
> Where that function is from the static library (libBrownie.a) which was not
> being linked properly from before. I think this is a fairly standard C++
> error, but any help would be appreciated. I do know enough to run these
> commands:
> (from the static library)
> nm libBrownie.a | grep __ZTV16NewickTreeWriter:
> U __ZTV16NewickTreeWriter
> 0000f7a0 S __ZTV16NewickTreeWriter
>
> (from the shared library which R builds):
> nm libBrownie.a | grep __ZTV16NewickTreeWriter
> U __ZTV16NewickTreeWriter
>
Unfortunately http://code.google.com/p/brownie/source/checkout doesn't even compile so I don't think we can help you any further. From experience I would still bet on the package flags being wrong (it's a bit tedious to debug since symbols are only resolved at load time, not at link time) but we can't tell without the package.
Cheers,
Simon
> Thanks!
>
>
>>> This step seems to work fine and if I run the ./configure script which is
>> generated from the autoconfig file,
>>
>> More trouble - you should never run configure by hand because it will
>> likely use wrong settings (unless it is written such that it attempts to
>> find R and run it to get flags) - R CMD INSTALL is what you need to use so
>> the correct architecture, compilers and flags are setup.
>>
>
> Yes, my config script uses R to supply the flags, so running configure seems
> to run okay....
>
>
>>
>> Cheers,
>> Simon
>>
>>
>>
>
>
>>
>>> the library builds properly on Mac OS.
>>> The problem manifests when installing the package:
>>>
>>> ** testing if installed package can be loaded
>>>
>>>
>>>> *** caught bus error ***
>>>
>>> address 0x0, cause 'non-existent physical address'
>>>
>>>
>>> Traceback:
>>>
>>> 1: dyn.load(file, DLLpath = DLLpath, ...)
>>>
>>> 2: library.dynam(lib, package, package.lib)
>>>
>>> 3: loadNamespace(package, c(which.lib.loc, lib.loc), keep.source =
>>> keep.source)
>>>
>>> 4: doTryCatch(return(expr), name, parentenv, handler)
>>>
>>> 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
>>>
>>> 6: tryCatchList(expr, classes, parentenv, handlers)
>>>
>>> 7: tryCatch(expr, error = function(e) { call <- conditionCall(e) if
>>> (!is.null(call)) { if (identical(call[[1L]], quote(doTryCatch)))
>>> call <- sys.call(-4L) dcall <- deparse(call)[1L]
>>> prefix <- paste("Error in", dcall, ": ") LONG <- 75L msg <-
>>> conditionMessage(e) sm <- strsplit(msg, "\n")[[1L]] w <-
>> 14L +
>>> nchar(dcall, type = "w") + nchar(sm[1L], type = "w") if (is.na
>> (w))
>>> w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
>>> type = "b") if (w > LONG) prefix <- paste(prefix, "\n
>>> ", sep = "") } else prefix <- "Error : " msg <- paste(prefix,
>>> conditionMessage(e), "\n", sep = "") .Internal(seterrmessage(msg[1L]))
>>> if (!silent && identical(getOption("show.error.messages"), TRUE))
>> {
>>> cat(msg, file = stderr()) .Internal(printDeferredWarnings())
>>> } invisible(structure(msg, class = "try-error"))})
>>>
>>> 8: try({ ns <- loadNamespace(package, c(which.lib.loc, lib.loc),
>>> keep.source = keep.source) dataPath <- file.path(which.lib.loc,
>> package,
>>> "data") env <- attachNamespace(ns, pos = pos, dataPath = dataPath,
>>> deps)})
>>>
>>> 9: library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return
>> =
>>> TRUE)
>>>
>>> 10: withCallingHandlers(expr, packageStartupMessage = function(c)
>>> invokeRestart("muffleMessage"))
>>>
>>> 11: suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,
>>> character.only = TRUE, logical.return = TRUE))
>>>
>>> 12: doTryCatch(return(expr), name, parentenv, handler)
>>>
>>> 13: tryCatchOne(expr, names, parentenv, handlers[[1L]])
>>>
>>> 14: tryCatchList(expr, classes, parentenv, handlers)
>>>
>>> 15: tryCatch(expr, error = function(e) { call <- conditionCall(e)
>> if
>>> (!is.null(call)) { if (identical(call[[1L]], quote(doTryCatch)))
>>> call <- sys.call(-4L) dcall <- deparse(call)[1L]
>>> prefix <- paste("Error in", dcall, ": ") LONG <- 75L msg <-
>>> conditionMessage(e) sm <- strsplit(msg, "\n")[[1L]] w <-
>> 14L +
>>> nchar(dcall, type = "w") + nchar(sm[1L], type = "w") if (is.na
>> (w))
>>> w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
>>> type = "b") if (w > LONG) prefix <- paste(prefix, "\n
>>> ", sep = "") } else prefix <- "Error : " msg <- paste(prefix,
>>> conditionMessage(e), "\n", sep = "") .Internal(seterrmessage(msg[1L]))
>>> if (!silent && identical(getOption("show.error.messages"), TRUE))
>> {
>>> cat(msg, file = stderr()) .Internal(printDeferredWarnings())
>>> } invisible(structure(msg, class = "try-error"))})
>>>
>>> 16: try(suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,
>>> character.only = TRUE, logical.return = TRUE)))
>>>
>>> 17: do_install_source(pkg_name, instdir, pkg, desc)
>>>
>>> 18: do_install(pkg)
>>>
>>> 19: tools:::.install_packages()
>>>
>>> aborting ...
>>>
>>> /opt/local/lib/R/bin/INSTALL: line 34: 1357 Done echo
>>> 'tools:::.install_packages()'
>>>
>>> 1358 Bus error | R_DEFAULT_PACKAGES= LC_COLLATE=C
>>> "${R_HOME}/bin/R" $myArgs --slave --args ${args}
>>>
>>> I'm not really familiar with Mac OS at all so any direction would be
>> great.
>>> Thanks!
>>> Conrad
>>>
>>> --
>>> Conrad Stack
>>> -----------------------
>>> PSU Department of Biology
>>> 208 Mueller Lab
>>> University Park, PA 16802
>>> cell: 814.409.8310
>>> email: conrad.stack at gmail.com
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-SIG-Mac mailing list
>>> R-SIG-Mac at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>>
>>>
>>
>>
>>
>
>
> --
> Conrad Stack
> -----------------------
> PSU Department of Biology
> 208 Mueller Lab
> University Park, PA 16802
> cell: 814.409.8310
> email: conrad.stack at gmail.com
>
>
>
> --
> Conrad Stack
> -----------------------
> PSU Department of Biology
> 208 Mueller Lab
> University Park, PA 16802
> cell: 814.409.8310
> email: conrad.stack at gmail.com
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>
More information about the R-SIG-Mac
mailing list