Trouble compiling packages from source on Mac OS

Hi all,

Since installing R 4.3.1 and RStudio 2023.06.2+561 on my MacBook Pro running Big Sur (11.7.8), I am having a lot of trouble installing any packages from Github - i.e. I am having trouble compiling things (although not everything). I have tried pretty much everything including altering my Makevars file in .R, installing a new version of gcc from Homebrew, installing Xcode Developer tools, deleting the Makevars file to see if that helps, but to no avail. I think this message may be informative:

** libs
using C compiler: ‘Apple clang version 13.0.0 (clang-1300.0.29.30)’
using C++ compiler: ‘Apple clang version 13.0.0 (clang-1300.0.29.30)’
using C++11
using SDK: ‘’

This suggests that maybe the SDK headers are missing? I don’t know. Does anyone have a quick fix for me? Last time this happened I spent hours fruitlessly typing things into Terminal and then worked out that just installing a newer version of R would fix it. Sadly that has not worked this time. Updating my operating system seems a radical step but I am willing to take it if nothing else works - but worried that will break something else.

Thanks!

Deborah.

What are some of the github packages that you are having trouble with?

BTW: with the upcoming release of Sonoma, Big Sur will drop off the list of supported versions for RStudio, which follows the Apple support schedule of the current and two most recent versions.

Thanks - specifically gganimate at the moment (I came to this problem because I was trying to install the developer version of gganimate to overcome a bug that seems to have arisen in the latest CRAN version). In trying this, it also attempts to install transformr and tweenr from Github, which also fails. I don't know if this string of warnings is informative:

* installing *source* package ‘tweenr’ ...
** using staged installation
** libs
using C compiler: ‘Apple clang version 13.0.0 (clang-1300.0.29.30)’
using C++ compiler: ‘Apple clang version 13.0.0 (clang-1300.0.29.30)’
using C++11
using SDK: ‘’
clang++ -arch x86_64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include' -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c along.cpp -o along.o
In file included from along.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include/cpp11/doubles.hpp:9:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include/cpp11/as.hpp:3:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace
using ::isfinite;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:742:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from along.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include/cpp11/doubles.hpp:9:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include/cpp11/as.hpp:3:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:771:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from along.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include/cpp11/doubles.hpp:9:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include/cpp11/as.hpp:3:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
make: *** [along.o] Error 1
ERROR: compilation failed for package ‘tweenr’
* removing ‘/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/tweenr’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/tweenr’

..but it suggests that there is something wrong with the XCode Developer Tools version of C++. At least I think so?

Thanks for your help.

Here's my transcript. I'll recharge my old Intel Airbook and see if the architecture makes the difference.

> devtools::install_github('thomasp85/tweenr')
Downloading GitHub repo thomasp85/tweenr@HEAD
── R CMD build ───────────────────────────────────
✔  checking for file ‘/private/var/folders/0j/3g7q2zss7fb55q5wqg9t141r0000gn/T/RtmpYVcAPM/remotesc3d564435d71/thomasp85-tweenr-2c893a1/DESCRIPTION’ ...
─  preparing ‘tweenr’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘tweenr_2.0.2.9000.tar.gz’
   
* installing *source* package ‘tweenr’ ...
** using staged installation
** libs
using C compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
using C++ compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
using C++11
using SDK: ‘’
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/cpp11/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c along.cpp -o along.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/cpp11/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c at.cpp -o at.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/cpp11/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c cpp11.cpp -o cpp11.o
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/cpp11/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c easing.c -o easing.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/cpp11/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c element.cpp -o element.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/cpp11/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c element_at.cpp -o element_at.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/cpp11/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c fill.cpp -o fill.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/cpp11/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c state.cpp -o state.o
clang++ -arch arm64 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o tweenr.so along.o at.o cpp11.o easing.o element.o element_at.o fill.o state.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/00LOCK-tweenr/00new/tweenr/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (tweenr)

Ugh thanks, I guess I will have to update my operating system eventually!

Thanks for your help.

Aha, I see that your clang++ version is quite different from mine! After the "using SDK" line I get:

clang++ -arch x86_64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include' -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c along.cpp -o along.o
In file included from along.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include/cpp11/doubles.hpp:9:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include/cpp11/as.hpp:3:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace

So that seems to be where the error is occurring? Everything is the same until "in file included"

EDIT: I think it may be the architecture that is making the difference! I can see you have a newer version of clang with your newer architecture.

Thanks again!

My Airbook recharged. It's on Big Sur too and I compiled ok.

Here is where I think the difference begins

Me:

clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c along.cpp -o along.o

You:

clang++ -arch x86_64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/cpp11/include' -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c along.cpp -o along.o

Maybe start by checking your clang++

(base) rc@Polo ~ % clang++ -v
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
* installing *source* package ‘tweenr’ ...
** using staged installation
** libs
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c along.cpp -o along.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c at.cpp -o at.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c cpp11.cpp -o cpp11.o
clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c easing.c -o easing.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c element.cpp -o element.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c element_at.cpp -o element_at.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c fill.cpp -o fill.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c state.cpp -o state.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o tweenr.so along.o at.o cpp11.o easing.o element.o element_at.o fill.o state.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-tweenr/00new/tweenr/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (tweenr)

You should not need a Makevars file, and you definitely do not need compilers from brew. In fact it it best to delete the ~/.R/Makevars file, and also the compilers from brew.

If you got rid of these and the installation still does not work, please show us the complete input and output, including the commands you run, and the full output. Thanks.

E.g. this is my output on R 4.3.1 patched:

❯ pak::pkg_install("thomasp85/tweenr")
✔ Loading metadata database ... done

→ Will install 1 package.
→ Will update 1 package.
→ Will download 1 CRAN package (1.99 MB), cached: 1 (0 B).
+ farver 2.1.0 → 2.1.1       ⬇ (1.99 MB)
+ tweenr         2.0.2.9000 👷🏾‍♀️🔧 (GitHub: 2c893a1)
? Do you want to continue (Y/n)
ℹ Getting 1 pkg (1.99 MB), 1 cached
✔ Got tweenr 2.0.2.9000 (source) (795.77 kB)
✔ Got farver 2.1.1 (x86_64-apple-darwin20) (1.99 MB)
✔ Downloaded 2 packages (2.78 MB) in 1.6s
✔ Installed farver 2.1.1  (50ms)
ℹ Packaging tweenr 2.0.2.9000
✔ Packaged tweenr 2.0.2.9000 (3.5s)
ℹ Building tweenr 2.0.2.9000
✔ Built tweenr 2.0.2.9000 (11.9s)
✔ Installed tweenr 2.0.2.9000 (github::thomasp85/tweenr@2c893a1) (31ms)
✔ 1 pkg + 8 deps: kept 5, upd 1, added 1, dld 2 (NA B) [26.4s]

Thanks for your reply! What has actually worked for me is upgrading my operating system to Ventura. I’m not really sure why this worked, but it did.

Hope this helps others. I also reinstalled R, XQuartz and gfortran as suggested on the CRAN site. Now to proceed with getting gganimate to work properly again.

1 Like

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.