Skip to content

Instantly share code, notes, and snippets.

@kevinushey
Created August 15, 2014 22:45
Show Gist options
  • Save kevinushey/69e454895376ab7792f3 to your computer and use it in GitHub Desktop.
Save kevinushey/69e454895376ab7792f3 to your computer and use it in GitHub Desktop.
Find packages that may have binary incompatibilities on Mac OS X
otool <- Sys.which("otool")
if (otool == "") {
stop("This utility requires 'otool' to run")
}
allPackages <- list.files(.libPaths(), full.names = TRUE)
stdLibsUsed <- lapply(allPackages, function(path) {
pkgName <- basename(path)
libPath <- file.path(path, "libs", paste0(pkgName, ".so"))
if (!file.exists(libPath)) {
return(character())
}
otoolOutput <- system2("otool", args = c("-L", libPath), stdout = TRUE)
c(
"libc++"[any(grepl("libc++", otoolOutput, fixed = TRUE))],
"libstdc++"[any(grepl("libstdc++", otoolOutput, fixed = TRUE))]
)
})
pkgsWithLibStdCpp <- allPackages[sapply(stdLibsUsed, function(x) {
"libstdc++" %in% x
})]
pkgsWithLibCpp <- allPackages[sapply(stdLibsUsed, function(x) {
"libc++" %in% x
})]
list(
"libstdc++" = pkgsWithLibStdCpp,
"libc++" = pkgsWithLibCpp
)
@kevinushey
Copy link
Author

If you see some packages linked to libstdc++ and others linked to libc++, you're probably going to have a bad time -- you should ensure all packages are using the same implementation of the C++ standard library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment