# Dealing with Catalina II

**URL:** <https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802>\
**Category:** RStan\
**Tags:** rstan\
**Created:** [November 7, 2019, 11:48pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802 "2019-11-07T23:48:44Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [November 8, 2019, 3:00pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/22 "2019-11-08T15:00:08Z")

</div>

Still get `Error in throw_exception() : this is the expected behavior`. I’ll rerun the example now.

---

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [November 8, 2019, 3:02pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/23 "2019-11-08T15:02:59Z")

</div>

I got the same

> Chain 1: Iteration: 1 / 2000 [0%] (Warmup)  
> [1] “Error in sampler$call\_sampler(args\_list[[i]]) : "  
> [2] " c++ exception (unknown reason)”  
> error occurred during calling the sampler; sampling not done

Here’s the verbose output:

> Compilation argument:  
> /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file91bf424c6003.cpp 2\> file91bf424c6003.cpp.err.txt  
> /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Users/torkarr/Library/R/3.6/library/Rcpp/include/" -I"/Users/torkarr/Library/R/3.6/library/RcppEigen/include/" -I"/Users/torkarr/Library/R/3.6/library/RcppEigen/include/unsupported" -I"/Users/torkarr/Library/R/3.6/library/BH/include" -I"/Users/torkarr/Library/R/3.6/library/StanHeaders/include/src/" -I"/Users/torkarr/Library/R/3.6/library/StanHeaders/include/" -I"/Users/torkarr/Library/R/3.6/library/rstan/include" -DEIGEN\_NO\_DEBUG -DBOOST\_DISABLE\_ASSERTS -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c file91bf424c6003.cpp -o file91bf424c6003.o  
> /usr/local/clang7/bin/clang++ -L/Library/Frameworks/R.framework/Resources/lib/libc++.1.dylib -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 file91bf424c6003.so file91bf424c6003.o -L/Users/torkarr/Library/R/3.6/library/StanHeaders/lib/ -lStanHeaders -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 3:04pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/24 "2019-11-08T15:04:44Z")

</div>

And

```
dlls <- getLoadedDLLs()
paths <- vapply(dlls, `[[`, "path", FUN.VALUE = character(1))
invisible(lapply(paths, function(path) {
  
  if (!file.exists(path))
    return(FALSE)
  
  output <- system(paste("otool -L", shQuote(path), "| grep libc++ || true"),
                   intern = TRUE)
  if (length(output) == 0)
    return(FALSE)
  
  writeLines(paste0(path, ":"))
  writeLines(output)
  
}))

```

still has /usr/lib/libc++.1.dylib at the end?

---

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [November 8, 2019, 3:06pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/25 "2019-11-08T15:06:17Z")

</div>

> /Users/torkarr/Library/R/3.6/library/Rcpp/libs/Rcpp.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.6.0)  
> /Users/torkarr/Library/R/3.6/library/scales/libs/scales.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/tidyselect/libs/tidyselect.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/dplyr/libs/dplyr.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/rstan/libs/rstan.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /var/folders/5p/dlcj\_kd94bx83r83k\_d77j54pspdk5/T//RtmpQ45ZaX/file91bf424c6003.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 3:08pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/26 "2019-11-08T15:08:24Z")

</div>

I don’t know how that is possible. We’ll need additional Mac expertise.

In the meantime, try changing

```
-L$(R_HOME)/lib/libc++.1.dylib

```

to

```
-L/usr/local/clang7/lib

```

in ~/.R/Makevars.

---

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [November 8, 2019, 3:12pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/27 "2019-11-08T15:12:38Z")

</div>

Now it sampled correctly…  
Your DLL code says this:

> /Users/torkarr/Library/R/3.6/library/Rcpp/libs/Rcpp.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.6.0)  
> /Users/torkarr/Library/R/3.6/library/scales/libs/scales.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/tidyselect/libs/tidyselect.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/dplyr/libs/dplyr.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/rstan/libs/rstan.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /var/folders/5p/dlcj\_kd94bx83r83k\_d77j54pspdk5/T//RtmpDpq1C9/file9780549a963b.so:  
> /usr/local/clang7/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)

And compilation arguments are:

> Compilation argument:  
> /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file9780549a963b.cpp 2\> file9780549a963b.cpp.err.txt  
> /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Users/torkarr/Library/R/3.6/library/Rcpp/include/" -I"/Users/torkarr/Library/R/3.6/library/RcppEigen/include/" -I"/Users/torkarr/Library/R/3.6/library/RcppEigen/include/unsupported" -I"/Users/torkarr/Library/R/3.6/library/BH/include" -I"/Users/torkarr/Library/R/3.6/library/StanHeaders/include/src/" -I"/Users/torkarr/Library/R/3.6/library/StanHeaders/include/" -I"/Users/torkarr/Library/R/3.6/library/rstan/include" -DEIGEN\_NO\_DEBUG -DBOOST\_DISABLE\_ASSERTS -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c file9780549a963b.cpp -o file9780549a963b.o  
> /usr/local/clang7/bin/clang++ -L/usr/local/clang7/lib -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 file9780549a963b.so file9780549a963b.o -L/Users/torkarr/Library/R/3.6/library/StanHeaders/lib/ -lStanHeaders -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation

I need to fetch my kids now so will check later this evening (Swedish time).

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 3:33pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/28 "2019-11-08T15:33:37Z")

</div>

Is `/Library/Frameworks/R.framework/Resources/lib/libc++1.dylib` a symlink to `/usr/lib/libc++.1.dylib` in Sweden?

---

<div class="post-metadata">

**Author:** ![mike-lawrence](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mike-lawrence/32/59_2.png) [@mike-lawrence](https://discourse.mc-stan.org/u/mike-lawrence)\
**Post date:** [November 8, 2019, 3:47pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/29 "2019-11-08T15:47:01Z")

</div>

Not sure if it helps at all, but in case any linux-based devs want to get hands-on with Catalina, I just found these instructions for setting it up as a VM (inc. auto-downloading the OS ISO): [https://github.com/foxlet/macOS-Simple-KVM/blob/master/README.md](https://github.com/foxlet/macOS-Simple-KVM/blob/master/README.md)

---

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [November 8, 2019, 4:08pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/30 "2019-11-08T16:08:36Z")

</div>

Well, in Sweden there’s no `libc++1.dylib` ;) But I have a `libc++.1.dylib` and it’s not a link:

> % ls -lsa libc++.1.dylib  
> 1656 -rwxrwxr-x 1 root admin 845100 Jul 6 04:12 libc++.1.dylib

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 4:26pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/31 "2019-11-08T16:26:52Z")

</div>

OK. Try agin with

```
-L$(R_HOME)/lib

```

in ~/.R/Makevars instead of

```
-L/usr/local/clang7/lib

```

---

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [November 8, 2019, 4:35pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/32 "2019-11-08T16:35:42Z")

</div>

Got an `unknown reason` during sampling again. Previously it sampled nicely with `-L/usr/local/clang7/lib`

Output below:

> Compilation argument:  
> /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB fileac4a36d3023f.cpp 2\> fileac4a36d3023f.cpp.err.txt  
> /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Users/torkarr/Library/R/3.6/library/Rcpp/include/" -I"/Users/torkarr/Library/R/3.6/library/RcppEigen/include/" -I"/Users/torkarr/Library/R/3.6/library/RcppEigen/include/unsupported" -I"/Users/torkarr/Library/R/3.6/library/BH/include" -I"/Users/torkarr/Library/R/3.6/library/StanHeaders/include/src/" -I"/Users/torkarr/Library/R/3.6/library/StanHeaders/include/" -I"/Users/torkarr/Library/R/3.6/library/rstan/include" -DEIGEN\_NO\_DEBUG -DBOOST\_DISABLE\_ASSERTS -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c fileac4a36d3023f.cpp -o fileac4a36d3023f.o  
> /usr/local/clang7/bin/clang++ -L/Library/Frameworks/R.framework/Resources/lib -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 fileac4a36d3023f.so fileac4a36d3023f.o -L/Users/torkarr/Library/R/3.6/library/StanHeaders/lib/ -lStanHeaders -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation

and,

> /Users/torkarr/Library/R/3.6/library/Rcpp/libs/Rcpp.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.6.0)  
> /Users/torkarr/Library/R/3.6/library/scales/libs/scales.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/tidyselect/libs/tidyselect.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/dplyr/libs/dplyr.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/rstan/libs/rstan.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /var/folders/5p/dlcj\_kd94bx83r83k\_d77j54pspdk5/T//Rtmp6fAMsg/fileac4a36d3023f.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 4:37pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/33 "2019-11-08T16:37:04Z")

</div>

Can you add a `-lc++` at the end of

```
SHLIB_CXX14LD = /usr/local/clang7/bin/clang++ -L$(R_HOME)/lib/"

```

in ~/.R/Makevars .

---

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [November 8, 2019, 4:59pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/34 "2019-11-08T16:59:53Z")

</div>

Same error with the sampling.

> Compilation argument:  
> /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB fileb7c99ed272e.cpp 2\> fileb7c99ed272e.cpp.err.txt  
> /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Users/torkarr/Library/R/3.6/library/Rcpp/include/" -I"/Users/torkarr/Library/R/3.6/library/RcppEigen/include/" -I"/Users/torkarr/Library/R/3.6/library/RcppEigen/include/unsupported" -I"/Users/torkarr/Library/R/3.6/library/BH/include" -I"/Users/torkarr/Library/R/3.6/library/StanHeaders/include/src/" -I"/Users/torkarr/Library/R/3.6/library/StanHeaders/include/" -I"/Users/torkarr/Library/R/3.6/library/rstan/include" -DEIGEN\_NO\_DEBUG -DBOOST\_DISABLE\_ASSERTS -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c fileb7c99ed272e.cpp -o fileb7c99ed272e.o  
> /usr/local/clang7/bin/clang++ -L/Library/Frameworks/R.framework/Resources/lib -lc++ -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 fileb7c99ed272e.so fileb7c99ed272e.o -L/Users/torkarr/Library/R/3.6/library/StanHeaders/lib/ -lStanHeaders -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation

> /Users/torkarr/Library/R/3.6/library/Rcpp/libs/Rcpp.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.6.0)  
> /Users/torkarr/Library/R/3.6/library/scales/libs/scales.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/tidyselect/libs/tidyselect.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/dplyr/libs/dplyr.so:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /Users/torkarr/Library/R/3.6/library/rstan/libs/rstan.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)  
> /var/folders/5p/dlcj\_kd94bx83r83k\_d77j54pspdk5/T//RtmpaaeUD3/fileb7c99ed272e.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 5:15pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/35 "2019-11-08T17:15:41Z")

</div>

And

```
example(cxxfunction, package = "inline", run.dontrun = TRUE)

```

links the DLLs to `/usr/lib/libc++.1.dylib` or to `/Library/Frameworks/R.framework/Resources/lib/libc++.1.dylib`?

---

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [November 8, 2019, 5:20pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/36 "2019-11-08T17:20:57Z")

</div>

I ran `example()` and then your DLL function

> /var/folders/5p/dlcj\_kd94bx83r83k\_d77j54pspdk5/T//RtmpPbjB1G/filec6655bfafc7a.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)  
> /Users/torkarr/Library/R/3.6/library/Rcpp/libs/Rcpp.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.6.0)  
> /var/folders/5p/dlcj\_kd94bx83r83k\_d77j54pspdk5/T//RtmpPbjB1G/filec6653ad5dcc3.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)  
> /var/folders/5p/dlcj\_kd94bx83r83k\_d77j54pspdk5/T//RtmpPbjB1G/filec6652e90a462.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)  
> /Users/torkarr/Library/R/3.6/library/RcppArmadillo/libs/RcppArmadillo.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.6.0)  
> /var/folders/5p/dlcj\_kd94bx83r83k\_d77j54pspdk5/T//RtmpPbjB1G/filec6651a1835d0.so:  
> /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 6:14pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/37 "2019-11-08T18:14:55Z")

</div>

OK. I can live with that. I changed the OP to look in `/usr/local/clang7/lib` rather than `$(R_HOME)/lib`.

---

<div class="post-metadata">

**Author:** ![coatless](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/coatless/32/2052_2.png) [@coatless](https://discourse.mc-stan.org/u/coatless)\
**Post date:** [November 8, 2019, 7:03pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/38 "2019-11-08T19:03:41Z")

</div>

@bgoodri Are you on Stan’s Slack? I could pop in there.

I’m fine with adding a modification to `~/.R/Makevars` that contains:

```bash
CXX14 = /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1
SHLIB_CXX14LD = /usr/local/clang7/bin/clang++ -L/usr/local/clang7/lib/

```

Let me know your preference.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 7:29pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/39 "2019-11-08T19:29:50Z")

</div>

I haven’t joined Stan’s slack because I’m afraid I would never be able to leave, but if you want to talk off Discourse, I’m happy to do that.

Adding

```
CXX14 = /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1
SHLIB_CXX14LD = /usr/local/clang7/bin/clang++ -L/usr/local/clang7/lib/

```

seems to work for Stan, but I’m not sure it is the ultimate solution. First, people using `Rcpp::sourceCpp` or `inline::cxxfunction` on Catalina will still get errors from exceptions by default using C++11 or C++98. You could make the broader change

```
CXX = /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1
SHLIB_CXXLD = /usr/local/clang7/bin/clang++ -L/usr/local/clang7/lib/
CXX11 = /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1
SHLIB_CXX11LD = /usr/local/clang7/bin/clang++ -L/usr/local/clang7/lib/
CXX14 = /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1
SHLIB_CXX14LD = /usr/local/clang7/bin/clang++ -L/usr/local/clang7/lib/
CXX17 = /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1
SHLIB_CXX17LD = /usr/local/clang7/bin/clang++ -L/usr/local/clang7/lib/

```

but I don’t know if that would adversely affect other packages that are implicitly relying on XCode to link. Stan, unlike almost all packages, enforces C++14 so only doing it for CXX14 and SHLIB\_CXX14LD is unlikely to affect too many other packages.

More broadly, I don’t know why `SHLIB_CXX{98,11,14,17}LD` on a Mac differs from the corresponding `CXX{98,11,14,17}`. On Linux, they seem to be the same. But I stumbled into this workaround by observing on a friend’s Mac that (in a shell)

```
`R CMD config SHLIB_CXX14LD` --version

```

was `clang++` from XCode, which was the reason for the conflict between LLVM-clang++ compiled code and XCode-libc++ . So, maybe R is just misconfigured for Macs?

I also don’t know why `-L/usr/local/clang7/lib` works for us but `-L$(R_HOME)/lib` does not work for us. The latter works for `Rcpp::sourceCpp` but the former works for `inline::cxxfunction`, which is what Stan calls. So, maybe the `$(R_HOME)/lib/libc++.1.dylib` that comes with the R binary for Mac was compiled by XCode or is wrong for some other weird reason.

BTW, I don’t think you have to upgrade to Catalina yourself to test whether there are issues with any of the above. You just need to compile / link some C++ code and see what `libc++.1.dylib` is picked up with @kevinushey’s test:

```
dlls <- getLoadedDLLs()
paths <- vapply(dlls, `[[`, "path", FUN.VALUE = character(1))
invisible(lapply(paths, function(path) {
  
  if (!file.exists(path))
    return(FALSE)
  
  output <- system(paste("otool -L", shQuote(path), "| grep libc++ || true"),
                   intern = TRUE)
  if (length(output) == 0)
    return(FALSE)
  
  writeLines(paste0(path, ":"))
  writeLines(output)
  
}))

```

---

<div class="post-metadata">

**Author:** ![coatless](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/coatless/32/2052_2.png) [@coatless](https://discourse.mc-stan.org/u/coatless)\
**Post date:** [November 8, 2019, 7:50pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/40 "2019-11-08T19:50:42Z")

</div>

> [@bgoodri](#):
>
> I haven’t joined Stan’s slack because I’m afraid I would never be able to leave, but if you want to talk off Discourse, I’m happy to do that.

Probably should of chatted off-discourse at the start, but in the future, feel free to ping me via e-mail (@illinois.edu) if something arises.

> [@bgoodri](#):
>
> So, maybe R is just misconfigured for Macs?

I think so. We might want to ping Simon. Though, he’s a bit busy. But, I’d like to avoid a repeat of this when R 4.0.0 is released in April. The toolchain is slated to move to `clang8` then.

> [@bgoodri](#):
>
> So, maybe the `$(R_HOME)/lib/libc++.1.dylib` that comes with the R binary for Mac was compiled by XCode or is wrong for some other weird reason.

I’ll investigate it a bit more.

> [@bgoodri](#):
>
> I also don’t know why `-L/usr/local/clang7/lib` works for us but `-L$(R_HOME)/lib` does not work for us.

I’m wondering if the reason for this is because `$(R_HOME)` isn’t set without enclosing the statement with backticks, e.g. :

```no-highlight
SHLIB_CXX14LD = /usr/local/clang7/bin/clang++ -L`$(R_HOME)/lib/libc++.1.dylib`

```

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 8, 2019, 7:56pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802/41 "2019-11-08T19:56:50Z")

</div>

> [@coatless](#):
>
> I’m wondering if the reason for this is because `$(R_HOME)` isn’t set without enclosing the statement with backticks

@torkar got `$(R_HOME)` to expand to the correct path without the backticks but that was somehow insufficient to get `inline::cxxfunction` to not link against `/usr/lib/libc++.1.dylib` which continues to be a mystery to me.

Anyway, I agree it would be good to get someone from CRAN to weigh in. I would be happy to help further, but all I know is collected at

> **[Catalina problems](https://github.com/stan-dev/rstan/wiki/Catalina-problems)**
>
> RStan, the R interface to Stan. Contribute to stan-dev/rstan development by creating an account on GitHub.

[Previous page](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802.md?page=1)

[Next page](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802.md?page=3)
