An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20100712/e8a0907d/attachment.pl>
Compiling problem:
5 messages · Conrad Stack, Simon Urbanek
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
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20100713/a127d06e/attachment.pl>
Thanks, Conrad,
finally, I can give you some more targeted suggestions. I'll cover several issues (those will bite you later), not just the one that breaks.
a) configure
You have the order of check switched - you're first checking for the compiler (AC_LANG etc.) and only then setting the right one from R. The order should be reversed since you first need to find the compiler and only then check it.
b) Brownie makefile
The one is really hard-wired so it won't work since you have flags like -m32 in there so you end up with things like g++ -arch x86_64 -m32 .. which cannot work. Also compilation should not include $(LNK_OPTIONS) [you don't need them at all since you're not linking anything anyway]. In fact it would be much better to just take the flags from R since you are also missing PIC flags and they will be needed: although you are compiling a static library it will be linked into a dynamic object so it has to be PIC.
c) Now, the real meat is in the linker flags in RBrownie - and the compiler actually tells you what the mistake is:
ld: warning: path './brownie_src/libBrownie.a' following -L not a directory
You didn't really mean to sdd the libBrownie.a directory to be the search path - you really meant to use the library so your configure should read
AC_SUBST([LDFLAGS],["brownie_src/libBrownie.a ${LIBS} ${RCPP_LIB} "])
... and with that it works.
Cheers,
Simon
On Jul 13, 2010, at 2:05 PM, Conrad Stack wrote:
Ah, sorry about that. I'm working off of this branch: svn checkout http://brownie.googlecode.com/svn/branches/brownie_jcs brownieTEST cd brownieTEST chmod +x build_r ./build_r That should start the build. Thanks! Conrad On Mon, Jul 12, 2010 at 3:58 PM, Simon Urbanek <simon.urbanek at r-project.org> wrote: 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
-- Conrad Stack ----------------------- PSU Department of Biology 208 Mueller Lab University Park, PA 16802 cell: 814.409.8310 email: conrad.stack at gmail.com
3 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20100716/e44dff03/attachment.pl>