Weiming-Hu / AnalogsEnsemble

The C++ and R packages for parallel ensemble forecasts using Analog Ensemble
https://weiming-hu.github.io/AnalogsEnsemble/
MIT License
18 stars 5 forks source link

Error during RAnEn installation #13

Closed Weiming-Hu closed 5 years ago

Weiming-Hu commented 5 years ago

Describe the bug I got the following error when install the RAnEn package.

> install.packages("https://github.com/Weiming-Hu/AnalogsEnsemble/raw/master/RAnalogs/releases/RAnEn_latest.tar.gz", repos = NULL)
Installing package into ‘/Users/wuh20/Library/R/3.5/library’
(as ‘lib’ is unspecified)
trying URL 'https://github.com/Weiming-Hu/AnalogsEnsemble/raw/master/RAnalogs/releases/RAnEn_latest.tar.gz'
Content type 'application/octet-stream' length 115962 bytes (113 KB)
==================================================
downloaded 113 KB

* installing *source* package ‘RAnEn’ ...
Checking whether R_HOME is already set? R_HOME = /usr/local/Cellar/r/3.5.0_1/lib/R
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/private/var/folders/z2/qq0ntf292kj8hy14ckfrmlp80000gp/T/Rtmpmbn6Nq/R.INSTALL27d92b7a8188/RAnEn':
configure: error: cannot run C++ compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
ERROR: configuration failed for package ‘RAnEn’
* removing ‘/Users/wuh20/Library/R/3.5/library/RAnEn’
* restoring previous ‘/Users/wuh20/Library/R/3.5/library/RAnEn’
Warning message:
In install.packages("https://github.com/Weiming-Hu/AnalogsEnsemble/raw/master/RAnalogs/releases/RAnEn_latest.tar.gz",  :
  installation of package ‘/var/folders/z2/qq0ntf292kj8hy14ckfrmlp80000gp/T//Rtmpf4qdEz/downloaded_packages/RAnEn_latest.tar.gz’ had non-zero exit status

My Makevars

CC=gcc-8
CXX=g++-8
CXX1X=g++-8
CXX11=g++-8
Weiming-Hu commented 5 years ago

And then I go ahead and extract a RAnEn release tarball file trying to install it manually. I got the following error messages.

geogadmins-MacBook-Air:RAnalogs wuh20$ R CMD install RAnEn/
* installing to library ‘/Users/wuh20/Library/R/3.5/library’
* installing *source* package ‘RAnEn’ ...
** libs
g++-8 -std=gnu++11 -I"/usr/local/Cellar/r/3.5.0_1/lib/R/include" -DNDEBUG  -I"/Users/wuh20/Library/R/3.5/library/Rcpp/include" -I"/Users/wuh20/Library/R/3.5/library/BH/include" -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include   -fPIC  -g -O2 -c AnEn.cpp -o AnEn.o
In file included from /Users/wuh20/Library/R/3.5/library/BH/include/boost/config.hpp:48,
                 from /Users/wuh20/Library/R/3.5/library/BH/include/boost/config/workaround.hpp:41,
                 from /Users/wuh20/Library/R/3.5/library/BH/include/boost/detail/workaround.hpp:8,
                 from /Users/wuh20/Library/R/3.5/library/BH/include/boost/array.hpp:34,
                 from /Users/wuh20/Library/R/3.5/library/BH/include/boost/multi_array/range_list.hpp:19,
                 from /Users/wuh20/Library/R/3.5/library/BH/include/boost/multi_array/extent_gen.hpp:17,
                 from /Users/wuh20/Library/R/3.5/library/BH/include/boost/multi_array/base.hpp:22,
                 from /Users/wuh20/Library/R/3.5/library/BH/include/boost/multi_array.hpp:26,
                 from Analogs.h:11,
                 from AnEn.h:11,
                 from AnEn.cpp:8:
/Users/wuh20/Library/R/3.5/library/BH/include/boost/config/stdlib/libstdcpp3.hpp:78:12: fatal error:unistd.h: No such file or directory
 #  include <unistd.h>
            ^~~~~~~~~~
compilation terminated.
make: *** [AnEn.o] Error 1
ERROR: compilation failed for package ‘RAnEn’
* removing ‘/Users/wuh20/Library/R/3.5/library/RAnEn’
* restoring previous ‘/Users/wuh20/Library/R/3.5/library/RAnEn’
Weiming-Hu commented 5 years ago

My LLVM version is:

geogadmins-MacBook-Air:~ wuh20$ llvm-gcc -v
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Weiming-Hu commented 5 years ago

I examined the config file, and found the following error:

configure:2110: checking whether we are cross compiling
configure:2118: /usr/local/bin/g++-8 -std=gnu++11 -o conftest -g -O2 -I/usr/local/opt/sqlite/include -L/usr/local/opt/sqlite/lib conftest.cpp  >&5
In file included from conftest.cpp:9:
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include-fixed/stdio.h:78:10: fatal error: _stdio.h: No such file or directory
 #include <_stdio.h>
          ^~~~~~~~~~
compilation terminated.
configure:2122: $? = 1
configure:2129: ./conftest
./configure: line 2131: ./conftest: No such file or directory
configure:2133: $? = 127
configure:2140: error: in `/Users/wuh20/github/AnalogsEnsemble/RAnalogs/releases/RAnEn':
configure:2142: error: cannot run C++ compiled programs.
Weiming-Hu commented 5 years ago

I tried to update Xcode because it looks like an environment issue.

I opened the Xcode and it asked for an update.

screen shot 2018-12-13 at 8 36 54 am

After this, I still have the configure error. So I went ahead and did more updates.

reference

softwareupdate --install -a
Weiming-Hu commented 5 years ago

At last, I can finally run the following command. Before, I was not able to even run this.

xcode-select --install

It still did not fix the problem. I then install the simulator from Xcode based on what I found here.

screen shot 2018-12-13 at 4 12 33 pm

Weiming-Hu commented 5 years ago

I almost tempted to say that this issue is related to the Mojave environment.

Here is my environment config from HomeBrew:

$ brew config
HOMEBREW_VERSION: 1.8.5-24-g99c7e9d
ORIGIN: https://github.com/Homebrew/brew
HEAD: 99c7e9d4ce8195f3cc13ab7139bd3447baefec3e
Last commit: 13 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: f62c4ef5aa20d86e7f0aca0a5141b347674fde67
Core tap last commit: 58 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
CPU: quad-core 64-bit broadwell
Homebrew Ruby: 2.3.7 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/bin/ruby
Clang: 10.0 build 1000
Git: 2.17.2 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_131
macOS: 10.14.2-x86_64
CLT: 10.1.0.0.1.1539992718
Xcode: 10.1
XQuartz: 2.7.11 => /opt/X11
Weiming-Hu commented 5 years ago

After I did more reading, I fix this out.

This is because the Mojave OS removed the /usr/include folder and this cause a series of problems when compilers are looking for system files in this folder.

To quote the release note of Apple Mojave:

The command line tools will search the SDK for system headers by default. However, some software may fail to build correctly against the SDK and require macOS headers to be installed in the base system under /usr/include. If you are the maintainer of such software, we encourage you to update your project to work with the SDK or file a bug report for issues that are preventing you from doing so. As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided. You can find this package at:

/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

So I ran the package at the specified location and things worked out great.

Thanks to the final resource that points me to the correct place.