Skip to content

Trouble compiling packages in R

3 messages · Jarrett Phillips, Simon Urbanek, Brian Ripley

#
Hi All,
I am new to the list and am running RStudio Version 1.4.1717 on macOS Big
Sur 11.4 and have R 4.1.1 installed.

I just re-installed Xcode as well as Command Line Tools via instructions at
https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/

I am attempting to build my package using devtools::build I have verified
that both Rcpp and RcppArmadillo are working properly.

However, when I build, I get the following error message

 Error: package or namespace load failed for ?HACSim? in dyn.load(file,
DLLpath = DLLpath, ...):
    unable to load shared object
'/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/00LOCK-HACSim/00new/HACSim/libs/HACSim.so':

 dlopen(/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/00LOCK-HACSim/00new/HACSim/libs/HACSim.so,
6): Symbol not found: ___addtf3
     Referenced from: /usr/local/lib/libquadmath.0.dylib
     Expected in: /usr/local/lib/libgcc_s_x86_64.1.dylib
    in /usr/local/lib/libquadmath.0.dylib
   Error: loading failed
   Execution halted
   ERROR: loading failed
?  removing
?/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/HACSim?
         -----------------------------------
   ERROR: package installation failed
Error in (function (command = NULL, args = character(), error_on_status =
TRUE,  :
  System command 'R' failed, exit status: 1, stdout + stderr (last 10
lines):
E>
dlopen(/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/00LOCK-HACSim/00new/HACSim/libs/HACSim.so,
6): Symbol not found: ___addtf3
E>   Referenced from: /usr/local/lib/libquadmath.0.dylib
E>   Expected in: /usr/local/lib/libgcc_s_x86_64.1.dylib
E>  in /usr/local/lib/libquadmath.0.dylib
E> Error: loading failed
E> Execution halted
E> ERROR: loading failed
E> * removing
?/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/HACSim?
E>       -----------------------------------
E> ERROR: package installation failed
Type .Last.error.trace to see where the error occurred

Here is the traceback:

Stack trace:

 1. devtools:::build("HACSim_OO")
 2. pkgbuild::build(path = pkg, dest_path = path, binary = binary,  ...
 3. withr::with_temp_libpaths(rcmd_build_tools(options$cmd, c(options$path,
 ...
 4. base:::force(code)
 5. pkgbuild:::rcmd_build_tools(options$cmd, c(options$path, options$args),
 ...
 6. pkgbuild:::with_build_tools(callr::rcmd_safe(..., env = env,  ...
 7. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE,  ...
 8. callr:::run_r(options)
 9. base:::with(options, with_envvar(env, do.call(processx::run,  ...
 10. base:::with.default(options, with_envvar(env, do.call(processx::run,
 ...
 11. base:::eval(substitute(expr), data, enclos = parent.frame())
 12. base:::eval(substitute(expr), data, enclos = parent.frame())
 13. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args =
real_c ...
 14. base:::force(code)
 15. base:::do.call(processx::run, c(list(bin, args = real_cmdargs,  ...
 16. (function (command = NULL, args = character(), error_on_status = TRUE,
 ...
 17. throw(new_process_error(res, call = sys.call(), echo = echo,  ...

 x System command 'R' failed, exit status: 1, stdout + stderr (last 10
lines):
E>
dlopen(/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/00LOCK-HACSim/00new/HACSim/libs/HACSim.so,
6): Symbol not found: ___addtf3
E>   Referenced from: /usr/local/lib/libquadmath.0.dylib
E>   Expected in: /usr/local/lib/libgcc_s_x86_64.1.dylib
E>  in /usr/local/lib/libquadmath.0.dylib
E> Error: loading failed
E> Execution halted
E> ERROR: loading failed
E> * removing
?/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/HACSim?
E>       -----------------------------------
E> ERROR: package installation failed


Any ideas?

Any assistance is warmly welcomed and greatly appreciated.

Cheers,

Jarrett
#
Jarrett,

you seem to have some ancient compilers in /usr/local. In order to avoid issue, I would strongly recommend removing the content of /usr/local (or putting it aside - see below). You don't need any extra tools on Big Sur, only standard Apple Xcode or CLT are needed (see R documentation).

Also please note that your github repository (https://github.com/jphill01/HACSim.R) has binary files checked in which is a bad idea, so you may want to fix that problem first.

Cheers,
Simon


to remove all files from /usr/local:
sudo rm -rf /usr/local/*

to put them aside:
sudo -i
cd /usr/local
mkdir .bak
mv * .bak/

to restore  if needed:
sudo -i
cd /usr/local
mv .bak/* .
rmdir .bak
#
On 26/01/2022 05:46, Simon Urbanek wrote:
Unless you need to compile Fortran code ... on x86_64 the manuals 
recommend installing gfortran in /usr/local/gfortran and using a 
complete path.

For some packages you need other tools such as pkg-config, and the 
Tcl/Tk support code is installed under /usr/local (as are some 
symlinks).  So I would nuance Simon's suggestion by adding that you 
should re-install R (preferably 4.1.2) once /usr/local/* has been moved 
aside.