为什么在我安装了OpenMP之后,rxode2不能构建模型

huangapple go评论111阅读模式
英文:

Why rxode2 cannot build model after I installed OpenMP

问题

I'm sorry, but the text you provided is quite lengthy and contains code snippets that may not be suitable for direct translation. Additionally, it appears to be a detailed technical issue related to software and package installation on a Mac, which may require specific expertise to address.

If you have specific questions or need assistance with certain parts of the text, please feel free to ask, and I'll do my best to provide concise answers or explanations.

英文:

EDIT 4 (2023/06/22)

I'm trying to create a PK model using rxode2 package. Unfortunately, I got an error message stating error building model when using rxode({...}) function. Since I'm using a Mac (OS version 12.6.6, Intel processor), I followed the instructions here and here since I saw the message that rxode2 has not detected OpenMP support and will run in single-threaded mode after I loaded the package.

At the end, this is what I did (for reproduction):

>1) Reinstall Xcode Command Line Tools:

  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. sudo xcode-select --install

However, this results in installing older sdk versions as well. I don't know if this could be related to Xcode that was used in the past. I have reinstalled Xcode but I still have my old projects showing up at Xcode startup and these may have been targeted to previous SDK versions. I'm not sure how to perform a complete removal (not only Xcode but also any settings/configuration files that could be linked to sdk ressources somewhere in my computer).

为什么在我安装了OpenMP之后,rxode2不能构建模型


>2) Check libomp:

  1. brew update && brew install libomp
  2. --> Warning: libomp 16.0.5 is already installed and up-to-date

>3) Update Makevars file:
Of note (1): I first made a mistake creating this file (a simple txt file using textedit and removing the .txt extention) in my working R directory. I then created it in (what I hope is the good location...) the .r folder located in my $HOME (/Users/username/.r/Makevars)
Of note (2): R could not locate gfortran. /usr/local/bin/gfortran is a symlink as ls -l /usr/local/bin/gfortran prints /usr/local/bin/gfortran -> ../Cellar/gcc/13.1.0/bin/gfortran. I then modified Makevars accordingly.
Currently, the Makevars file looks like this:

  1. LOC=/usr/local/Cellar/gcc/13.1.0
  2. CC=$(LOC)/bin/gcc-13 -fopenmp
  3. CXX=$(LOC)/bin/g++-13 -fopenmp
  4. CXX11=$(LOC)/bin/g++-13 -fopenmp
  5. CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
  6. CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
  7. LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/
  8. CPPFLAGS=-I$(LOC)/include -I/usr/local/include
  9. FLIBS=-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/13/gcc/x86_64-apple-darwin21 -L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/ -lgfortran -lquadmath -lm
  10. CXX1X=$(LOC)/bin/g++-13
  11. CXX98=$(LOC)/bin/g++-13
  12. CXX14=$(LOC)/bin/g++-13
  13. CXX17=$(LOC)/bin/g++-13

>4) Install data.table package from source to see if something's going wrong.
Aside from many warnings (-pedantic flag enabled), I get the following error (as we can see, it uses MacOSX12.sdk even though the last version available is MacOSX13.1.sdk, cf image above):

install.packages("data.table", type = "source")

  1. ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd' for architecture x86_64

>5) Reorder $PATH
As pointed out in this post, the 'tapi file' issue can be caused by the wrong ld command being used when '$HOME/anaconda3/bin/ld' path is preceding '$HOME/usr/bin'.
Since which -a ld returns Users/username/anaconda3/bin/ld (I have Anaconda activated), I added export PATH=/usr/bin:$PATH at the end of the .bash_profile file in $HOME and then run source ~\.bash_profile into the terminal to have it take effect.

.bash_profile file

  1. export JAVA_HOME=$(/usr/libexec/java_home)
  2. # Setting PATH for Python 3.7
  3. # The original version is saved in .bash_profile.pysave
  4. PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
  5. export PATH
  6. # >>> conda initialize >>>
  7. # !! Contents within this block are managed by 'conda init' !!
  8. __conda_setup="$('/Users/username/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
  9. if [ $? -eq 0 ]; then
  10. eval "$__conda_setup"
  11. else
  12. if [ -f "/Users/username/anaconda3/etc/profile.d/conda.sh" ]; then
  13. . "/Users/username/anaconda3/etc/profile.d/conda.sh"
  14. else
  15. export PATH="/Users/username/anaconda3/bin:$PATH"
  16. fi
  17. fi
  18. unset __conda_setup
  19. # <<< conda initialize <<<
  20. export PATH=/usr/bin:$PATH

And now

  1. $ which -a ld
  2. /usr/bin/ld # it is now preceding $HOME/anaconda3/bin/ld
  3. /Users/username/anaconda3/bin/ld
  4. /usr/bin/ld

But still install.packages("data.table", type = "source") returns

  1. ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd' for architecture x86_64

>6) Remove older SDK files
After removing MacOSX11* and MacOSX12* .sdk files:

为什么在我安装了OpenMP之后,rxode2不能构建模型

install.packages("data.table", type = "source") returns

  1. ld: library not found for -lz

Could it be that the system is looking for MacOSX12.sdk exclusively? After it has been removed, it cannot target the most recent sdk files. MacOSX.sdk and MacOSX13.sdk are symlinks pointing to MacOSX13.1.sdk

  1. ls -l /Library/Developer/CommandLineTools/SDKs/
  2. total 0
  3. lrwxr-xr-x 1 root wheel 14 15 jui 10:03 MacOSX.sdk -> MacOSX13.1.sdk
  4. drwxr-xr-x 7 root wheel 224 12 nov 2022 MacOSX13.1.sdk
  5. lrwxr-xr-x 1 root wheel 14 15 jui 10:02 MacOSX13.sdk -> MacOSX13.1.sdk

I tried to google related issues, and I found this post where it looks like Xcode and SDK versions need to be closely related. Maybe could this problem arise because the MacOS SDK version that is used is MacOSX12 ? Any idea why MacOSX.sdk/MacOSX13.*.sdk cannot be targeted ?


>7) Trying with macrtools
I installed the development version of macrtools R package from GitHub (as it has superseded the r-macos-rtools installer package). I followed these instructions after removing the Command line tools folder containing all MacOSX* .sdk files:

  1. remotes::install_github("coatless-mac/macrtools")
  2. macrtools::macos_rtools_install()
  3. # Congratulations!
  4. # Xcode CLI, Gfortran, and R developer binaries have been installed successfully.

But then two new elements come up:
i) In contrast with xcode-select --install, macrtools::macos_rtools_install() only installs MacOSX12 and MacOSX13 sdk files (not MacOSX11).

为什么在我安装了OpenMP之后,rxode2不能构建模型

ii) However:

  1. macrtools::is_xcode_cli_installed()
  2. # FALSE

It says that Xcode CLI is not installed (even though SDK files are now present). The same thing occurs after trying to specifically install Xcode CLI:

  1. macrtools::xcode_cli_install()
  2. # Finding available software
  3. # Downloading Command Line Tools for Xcode
  4. # Downloaded Command Line Tools for Xcode
  5. # Installing Command Line Tools for Xcode
  6. # Done with Command Line Tools for Xcode
  7. # Done.
  8. macrtools::is_xcode_cli_installed()
  9. # FALSE
  1. macrtools::is_gfortran_installed()
  2. # TRUE
  1. macrtools::recipes_binary_install('r-base-dev')
  2. # No error
  1. install.packages("data.table", type = "source")
  2. # ** R
  3. # ** inst
  4. # ** byte-compile and prepare package for lazy loading
  5. # ** help
  6. # *** installing help indices
  7. # ** building package indices
  8. # ** installing vignettes
  9. # ** testing if installed package can be loaded from temporary location
  10. # ** checking absolute paths in shared objects and dynamic libraries
  11. # ** testing if installed package can be loaded from final location
  12. # ** testing if installed package keeps a record of temporary installation path
  13. # * DONE (data.table)

I'm not getting the message error unsupported tapi file type anymore :). But still, OpenMP is not detected:

  1. > library(data.table)
  2. # data.table 1.14.8 using 1 threads (see ?getDTthreads). Latest news: r-datatable.com
  3. # **********
  4. # This installation of data.table has not detected OpenMP support. It should still work but in single-threaded mode.

>8) Running {rxode2}
It is now possible to build a PK model without getting an error. However, many similar warnings show up (because of the -pedantic flag in Makevars ?) and I was wondering if they were related to OpenMP non-detection:

  1. ppk_mode = rxode({
  2. centr(0) = 0;
  3. TVCl = THETA_Cl*(CLCREAT/120)^0.8*(0.7^DIAL);
  4. TVVc = THETA_Vc*(WT/70) *(0.5^DIAL);
  5. TVVp = THETA_Vp;
  6. ...
  7. })
  8. # /usr/local/include/stdlib.h:291:20: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
  9. # int cgetnext(char **, char **);
  10. # ^
  11. # /usr/local/include/stdlib.h:291:20: note: insert '_Nullable' if the pointer may be null
  12. # int cgetnext(char **, char **);
  13. # ^
  14. # _Nullable
  15. # /usr/local/include/stdlib.h:291:20: note: insert '_Nonnull' if the pointer should never be null
  16. # int cgetnext(char **, char **);
  17. # And many other similar warnings.

>9) gfortran reinstallation and Makevars update
After uninstalling and reinstalling gfortran with {macrtools}, it is still located at the same location /usr/local/Cellar/gcc/13.1.0/...

  1. ls -l /usr/local/bin/gfortran
  2. # lrwxr-xr-x [...] /usr/local/bin/gfortran -> ../Cellar/gcc/13.1.0/bin/gfortran

And

  1. ls /usr/local/gfortran/lib/gcc/
  2. # No such file or directory

Also, running set into the terminal prints x86_64-apple-darwin21 which is different from the platform mentioned by sessionInfo() in R that displays x86_64-apple-darwin20. I'm not sure what {macrtools} did at the end.

This is how the current Makevars file looks like:

  1. LOC=/usr/local/Cellar/gcc/13.1.0
  2. CC=$(LOC)/bin/gcc-13 -fopenmp
  3. CXX=$(LOC)/bin/g++-13 -fopenmp
  4. CXX11=$(LOC)/bin/g++-13 -fopenmp
  5. CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
  6. CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
  7. LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/
  8. CPPFLAGS=-I$(LOC)/include -I/usr/local/include
  9. FLIBS=-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/13/gcc/x86_64-apple-darwin21/13 -L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/ -lgfortran -lquadmath -lm
  10. CXX1X=$(LOC)/bin/g++-13
  11. CXX11=/usr/local/gfortran/bin/g++
  12. CXX98=$(LOC)/bin/g++-13
  13. CXX14=$(LOC)/bin/g++-13
  14. CXX17=$(LOC)/bin/g++-13

Unfortunately I get again the tapi error with MacOSX12.sdk that is used:

install.packages("data.table", type = "source")

  1. ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd' for architecture x86_64

I followed the same {macrtools} instructions as before, but I cannot get rid this time of the tapi error message and MacOSX12.sdk issue. During this {macrtools} process, I noticed that it downloaded resources in a darwin20 folder from 'mac.R-project.org' (cf below)

  1. Downloading Command Line Tools for Xcode
  2. Downloaded Command Line Tools for Xcode
  3. Installing Command Line Tools for Xcode
  4. Done with Command Line Tools for Xcode
  5. Done.
  6. gfortran was already installed! ...
  7. Downloading https://mac.R-project.org/bin/REPOS ...
  8. Using repository https://mac.R-project.org/bin/darwin20/x86_64 ...
  9. Downloading index https://mac.R-project.org/bin/darwin20/x86_64/PACKAGES ...
  10. Downloading binary: https://mac.R-project.org/bin/darwin20/x86_64/xz-5.4.2-darwin.20-x86_64.tar.xz ...
  11. trying URL 'https://mac.R-project.org/bin/darwin20/x86_64/xz-5.4.2-darwin.20-x86_64.tar.xz'
  12. Content type 'application/octet-stream' length 559568 bytes (546 KB)
  13. ==================================================
  14. downloaded 546 KB
  15. Installing: xz-5.4.2-darwin.20-x86_64.tar.xz into '/opt/R/x86_64' ...
  16. ...

For a reason I cannot explain, reproducing the same steps with macrtools results now again in the tapi error. Could it be related to any darwin version discrepancy ?

Of note, I upgraded MacOS to Monterey a few days ago. I reinstalled XQuartz as well. Is there a way to get rid of all these gfortran/gcc, command line tools and SDK-related issues to start from scratch with a clean R / Fortan / SDK / etc. environment ?


>10) Extra information - SessionInfo()

为什么在我安装了OpenMP之后,rxode2不能构建模型

It shows that x86_64-apple-darwin20 platform version is used (and not darwin21 that is installed on my computer and that is the one in Makevars). But changing 21 to 20 in Makevars does not seem to have an influence.


>11) Cleaning and starting again
Since things look complicated, I uninstalled libomp, lightgbm, llvm, Xcode command line tools and anaconda.

  1. brew uninstall libomp
  2. Error: Refusing to uninstall /usr/local/Cellar/libomp/16.0.5
  3. because it is required by lightgbm, which is currently installed.
  4. You can override this and force removal with:
  5. brew uninstall --ignore-dependencies libomp
  1. brew uninstall lightgbm
  2. Uninstalling /usr/local/Cellar/lightgbm/3.3.5... (98 files, 18.1MB)
  1. brew uninstall libomp
  2. Uninstalling /usr/local/Cellar/libomp/16.0.5... (7 files, 1.7MB)
  1. brew uninstall llvm
  2. Uninstalling /usr/local/Cellar/llvm/16.0.5... (6,779 files, 1.6GB)

Regarding Anaconda cleaning, I followed instructions here

  1. conda install anaconda-clean
  1. anaconda-clean --yes
  2. Backup directory: /Users/username/.anaconda_backup/2023-06-22T181652
  1. rm -rf ~/anaconda3

I also removed this in ~/.bash_profile

  1. # >>> conda initialize >>>
  2. # !! Contents within this block are managed by 'conda init' !!
  3. __conda_setup="$('/Users/username/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /de$
  4. if [ $? -eq 0 ]; then
  5. eval "$__conda_setup"
  6. else
  7. if [ -f "/Users/username/opt/anaconda3/etc/profile.d/conda.sh" ]; then
  8. . "/Users/username/opt/anaconda3/etc/profile.d/conda.sh"
  9. else
  10. export PATH="/Users/username/opt/anaconda3/bin:$PATH"
  11. fi
  12. fi
  13. unset __conda_setup
  14. # <<< conda initialize <<<

Now, bash_profile looks like this:

  1. export JAVA_HOME=$(/usr/libexec/java_home)
  2. # Setting PATH for Python 3.7
  3. # The original version is saved in .bash_profile.pysave
  4. PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
  5. export PATH
  1. $PATH
  2. -bash: /Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin: No such file or directory

However, I noticed that in addition to have anaconda3 files in ~/anaconda3, I also found them in /opt/anaconda3 as mentioned in bash_profile, along with gfortran (among others):

为什么在我安装了OpenMP之后,rxode2不能构建模型

I also found that libomp.dylib is in /opt/anaconda3/lib:

为什么在我安装了OpenMP之后,rxode2不能构建模型

Is this strange or is it something expected ? Should I also remove anaconda3 from this folder ?

  1. which gfortran
  2. # returns nothing, (i.e., expected since /opt is not in $PATH ?)

And lastly,

  1. rm -rf /Library/Developer/CommandLineTools
  2. xcode-select --install

Now, I reinstalled a few things and followed these instructions from here and here:

  1. curl -O https://mac.r-project.org/openmp/openmp-14.0.6-darwin20-Release.tar.gz # since my Apple clang version is 1400.x
  2. sudo tar fvxz openmp-14.0.6-darwin20-Release.tar.gz -C /

After unpacking, I indeed find these files:

  1. /usr/local/lib/libomp.dylib
  2. /usr/local/include/ompt.h
  3. /usr/local/include/omp.h
  4. /usr/local/include/omp-tools.h

I added the following lines to $HOME/.R/Makevars that now contains only these lines:

  1. CPPFLAGS += -I/usr/local/include -Xclang -fopenmp
  2. LDFLAGS += -L/usr/local/lib -lomp

As proposed here (item 6), I created and compiled omp_test.c, and then called the compiled C function from R, and got:

  1. OpenMP threads available: 8

>12) Testing with data.table and rxode2
Aftef being so excited that OpenMP seems to work, I checked with data.table and rxode2 packages

  1. install.packages("data.table", type = "source")
  2. # Many warnings like /usr/local/include/stdlib.h:346:37: note: insert '_Nonnull' if the pointer should never be null
  3. # But installation successful
  4. library(data.table)
  5. # data.table 1.14.8 using 4 threads (see ?getDTthreads). Latest news: r-datatable.com

Becoming more and more confident, I tried with rxode2. However...

  1. install.packages("rxode2", type = "source")
  2. [...]
  3. using C compiler: Apple clang version 14.0.0 (clang-1400.0.29.202)’
  4. using Fortran compiler: GNU Fortran (GCC) 12.2.0
  5. using C++ compiler: Apple clang version 14.0.0 (clang-1400.0.29.202)’
  6. **using SDK: MacOSX13.1.sdk ----> which was empty previously, this is good news!**
  7. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:642:26: error: no template named 'numeric_limits'
  8. bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
  9. ^
  10. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:642:60: error: no template named 'numeric_limits'
  11. bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
  12. ^
  13. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:18: error: no template named 'numeric_limits'
  14. int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
  15. ^
  16. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:50: error: no template named 'numeric_limits'
  17. int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
  18. ^
  19. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:648:17: error: no template named 'numeric_limits'
  20. static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
  21. ^
  22. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:651:25: error: no template named 'numeric_limits'
  23. return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
  24. ^
  25. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:651:58: error: no template named 'numeric_limits'
  26. return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
  27. ^
  28. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:661:16: error: no template named 'numeric_limits'
  29. using _Lim = numeric_limits<_IntT>;
  30. ^
  31. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:664:12: error: use of undeclared identifier '_Lim'
  32. return _Lim::max();
  33. ^
  34. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:665:21: error: use of undeclared identifier '_Lim'
  35. } else if (__r <= _Lim::lowest()) {
  36. ^
  37. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:666:12: error: use of undeclared identifier '_Lim'
  38. return _Lim::min();
  39. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstdlib:138:9: error: target of using declaration conflicts with declaration already in scope
  40. using ::abs _LIBCPP_USING_IF_EXISTS;
  41. ^
  42. /usr/local/include/stdlib.h:132:6: note: target of using declaration
  43. int abs(int) __pure2;
  44. ^
  45. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: conflicting declaration
  46. using ::abs _LIBCPP_USING_IF_EXISTS;
  47. ^
  48. In file included from RcppExports.cpp:2:
  49. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
  50. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
  51. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
  52. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:853:1: error: declaration conflicts with target of using declaration already in scope
  53. abs(const complex<_Tp>& __c)
  54. ^
  55. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: target of using declaration
  56. using ::abs _LIBCPP_USING_IF_EXISTS;
  57. ^
  58. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:9: note: using declaration
  59. using ::abs _LIBCPP_USING_IF_EXISTS;
  60. ^
  61. In file included from RcppExports.cpp:2:
  62. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
  63. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
  64. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
  65. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:910:16: error: reference to unresolved using declaration
  66. return abs(__c.real());
  67. ^
  68. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
  69. using ::abs _LIBCPP_USING_IF_EXISTS;
  70. ^
  71. In file included from RcppExports.cpp:2:
  72. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
  73. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
  74. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
  75. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:912:16: error: reference to unresolved using declaration
  76. return abs(__c.imag());
  77. ^
  78. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
  79. using ::abs _LIBCPP_USING_IF_EXISTS;
  80. ^
  81. In file included from RcppExports.cpp:2:
  82. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
  83. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
  84. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
  85. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:969:16: error: reference to unresolved using declaration
  86. __re = abs(__re);
  87. ^
  88. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
  89. using ::abs _LIBCPP_USING_IF_EXISTS;
  90. ^
  91. In file included from RcppExports.cpp:2:
  92. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
  93. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
  94. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
  95. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:1022:29: error: reference to unresolved using declaration
  96. return complex<_Tp>(log(abs(__x)), arg(__x));
  97. ^
  98. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
  99. using ::abs _LIBCPP_USING_IF_EXISTS;
  100. ^
  101. In file included from RcppExports.cpp:2:
  102. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
  103. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
  104. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
  105. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:1049:23: error: reference to unresolved using declaration
  106. return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
  107. ^
  108. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
  109. using ::abs _LIBCPP_USING_IF_EXISTS;
  110. ^
  111. In file included from RcppExports.cpp:2:
  112. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
  113. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
  114. In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
  115. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:1174:33: error: reference to unresolved using declaration
  116. return complex<_Tp>(abs(__x.real()), __x.imag());
  117. ^
  118. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
  119. using ::abs _LIBCPP_USING_IF_EXISTS;
  120. ^
  121. fatal error: too many errors emitted, stopping now [-ferror-limit=]
  122. 20 errors generated.
  123. make: *** [RcppExports.o] Error 1
  124. ERROR: compilation failed for package rxode2

Unfortunately, there seems to be something missing when trying to install rxode2. Did I forget to reinstall anything ? I also found here some problems related to a wrong value of CMAKE_OSX_SYSROOT and heard about header files to link to usr/local/include. Or even something missing in ~/.R/Makevars ? I really don't know what sould be done next.

答案1

得分: 1

https://github.com/nlmixr2/nlmixr2/discussions/26

此外,如果您在那个帖子上发帖,我认为John可能会有一些建议。

英文:

Have you tried this

https://github.com/nlmixr2/nlmixr2/discussions/26

Also I think that John may have some tips if you post on the thread there.

答案2

得分: 0

感谢提供额外的细节!我有一些想法。

首先,在终端中运行命令which gfortran(在终端应用程序中,或在Rstudio的终端选项卡中),你会得到输出:"/usr/local/bin/gfortran"吗?还是其他内容?

如果你得到"/usr/local/bin/gfortran",并且目录"/usr/local/gfortran"存在(即在终端中运行cd /usr/local/gfortran; ls会显示"bin include lib libexec share"),则删除~.R/Makevars中的所有内容,只包含以下这些行:

  1. LOC=/usr/local/gfortran
  2. CC=$(LOC)/bin/gcc -fopenmp
  3. CXX=$(LOC)/bin/g++ -fopenmp
  4. CXX11 = $(LOC)/bin/g++ -fopenmp
  5. CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
  6. CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
  7. LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/lib
  8. CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/include
  9. FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
  10. CXX1X=/usr/local/gfortran/bin/g++
  11. CXX98=/usr/local/gfortran/bin/g++
  12. CXX11=/usr/local/gfortran/bin/g++
  13. CXX14=/usr/local/gfortran/bin/g++
  14. CXX17=/usr/local/gfortran/bin/g++

然后再次从源代码安装data.table:

  1. install.packages("data.table", type = "source")

我希望这可以解决问题,但如果不行,请编辑你的问题,提供which gccreadlink -f 'the output of "which gcc"'(例如,readlink -f /usr/bin/gcc)、readlink -f gccgcc --version的输出,我将进一步指导。


编辑 1

根据你的搜索,brew成功安装了gfortran,但安装位置不是在/usr/local/gfortran,很可能安装在"/usr/local/Cellar/gcc/"。

如果ls /usr/local/Cellar/gcc/的输出是"13.1.0",并且你将.R/Makevars更改为以下内容,我相当有信心这会解决你的问题:

  1. LOC=/usr/local/Cellar/gcc/13.1.0/
  2. CC=$(LOC)/bin/gcc-13 -fopenmp
  3. CXX=$(LOC)/bin/g++-13 -fopenmp
  4. CXX11=$(LOC)/bin/g++-13 -fopenmp
  5. CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
  6. CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
  7. LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/
  8. CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/include
  9. FLIBS=-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/13/gcc/x86_64-apple-darwin22 -L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/ -lgfortran -lquadmath -lm
  10. CXX1X=$(LOC)/bin/g++-13
  11. CXX98=$(LOC)/bin/g++-13
  12. CXX14=$(LOC)/bin/g++-13
  13. CXX17=$(LOC)/bin/g++-13

然后再次从源代码安装data.table,以查看是否使用openMP进行构建:

  1. install.packages("data.table", type = "source")
  2. library(data.table)
  3. #(应该会得到消息,类似于"data.table 1.14.8 using >1 threads")

我希望这会奏效,但如果不行,下一步是检查openMP是否已安装并可以被编译器找到。


编辑 2

显然已安装了OpenMP,但我无法重现SDK版本与命令行工具版本的问题,因此我很难进行故障排除。关于“从/Library/Frameworks/R.framework/Resources/include/R.h:71包含文件,从data.table.h:3中:/Library/Frameworks/R.framework/Resources/include/R_ext/Complex.h:80:6:警告:ISO C99不支持无名结构/联合体[-Wpedantic]”的警告,这些不是错误,它们会打印出来,因为使用了“-pedantic”标志;你可以忽略它们。

如果你在Makevars文件中删除对SDK的引用,是否仍然会收到“tapi file”错误?也就是说,将你的Makevars更改为以下内容:

  1. LOC=/usr/local/Cellar/gcc/13.1.0/
  2. CC=$(LOC)/bin/gcc-13 -fopenmp
  3. CXX=$(LOC)/bin/g++-13 -fopenmp
  4. CXX11=$(LOC)/bin/g++-13 -fopenmp
  5. CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
  6. CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
  7. LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/
  8. CPPFLAGS=-I$(LOC)/include -I/usr/local/include
  9. FLIBS=-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/13/gcc/x86_64-apple-darwin21 -L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/ -lgfortran -lquadmath -lm
  10. CXX1X=$(LOC)/bin/g++-13
  11. CXX98=$(LOC)/bin/g++-13
  12. CXX14=$(LOC)/bin/g++-13
  13. CXX17=$(LOC)/bin/g++-13
  14. <details>
  15. <summary>英文:</summary>
  16. ## Original answer:
  17. Thanks for including the extra details! I&#39;ve got some ideas.
  18. First, if you run the command `which gfortran` in a terminal (in the terminal app, or inside the terminal tab of Rstudio), do you get the output: &quot;/usr/local/bin/gfortran&quot;? Or something else?
  19. If you get &quot;/usr/local/bin/gfortran&quot;, and the directory &quot;/usr/local/gfortran&quot; exists (i.e. in the terminal `cd /usr/local/gfortran; ls` prints &quot;bin include lib libexec share&quot;), delete everything in your ~.R/Makevars and include only these lines:

LOC=/usr/local/gfortran
CC=$(LOC)/bin/gcc -fopenmp
CXX=$(LOC)/bin/g++ -fopenmp
CXX11 = $(LOC)/bin/g++ -fopenmp

CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/lib
CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/include

FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX1X=/usr/local/gfortran/bin/g++
CXX98=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
CXX14=/usr/local/gfortran/bin/g++
CXX17=/usr/local/gfortran/bin/g++

  1. Then install data.table from source again:
  2. ``` r
  3. install.packages(&quot;data.table&quot;, type = &quot;source&quot;)

I'm hoping that will solve the problem, but if not, please edit your question with the output of which gcc, readlink -f &#39;the output of &quot;which gcc&quot;&#39; (e.g. readlink -f /usr/bin/gcc), readlink -f gcc and gcc --version and I'll work out the next steps.


Edit 1

Based on your sleuthing, brew successfully installed gfortran but not in /usr/local/gfortran. It's very likely installed in "/usr/local/Cellar/gcc/".

If ls /usr/local/Cellar/gcc/ has the output "13.1.0", and you change your .R/Makevars to the following, I'm fairly confident it will solve your problem:

  1. LOC=/usr/local/Cellar/gcc/13.1.0/
  2. CC=$(LOC)/bin/gcc-13 -fopenmp
  3. CXX=$(LOC)/bin/g++-13 -fopenmp
  4. CXX11=$(LOC)/bin/g++-13 -fopenmp
  5. CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
  6. CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
  7. LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/
  8. CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/include
  9. FLIBS=-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/13/gcc/x86_64-apple-darwin22 -L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/ -lgfortran -lquadmath -lm
  10. CXX1X=$(LOC)/bin/g++-13
  11. CXX98=$(LOC)/bin/g++-13
  12. CXX14=$(LOC)/bin/g++-13
  13. CXX17=$(LOC)/bin/g++-13

Then install data.table from source again to see if it built using openMP:

install.packages("data.table", type = "source")
library(data.table)
#(should get a message like "data.table 1.14.8 using >1 threads")
I'm hoping that will work, but if it doesn't, next step is to check that openMP is installed and can be located by the compiler.


Edit 2

OpenMP is clearly installed, but I can't reproduce the issue with the SDK version vs command line tools, so I'm struggling to troubleshoot it. Regarding the In file included from /Library/Frameworks/R.framework/Resources/include/R.h:71, from data.table.h:3: /Library/Frameworks/R.framework/Resources/include/R_ext/Complex.h:80:6: warning: ISO C99 doesn&#39;t support unnamed structs/unions [-Wpedantic] warnings, these aren't errors and they are printed as the -pedantic flag is used; you can ignore them.

If you remove the references to SDK in your Makevars file, do you still get the 'tapi file' error? I.e. change your Makevars to the following:

  1. LOC=/usr/local/Cellar/gcc/13.1.0/
  2. CC=$(LOC)/bin/gcc-13 -fopenmp
  3. CXX=$(LOC)/bin/g++-13 -fopenmp
  4. CXX11=$(LOC)/bin/g++-13 -fopenmp
  5. CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
  6. CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
  7. LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/
  8. CPPFLAGS=-I$(LOC)/include -I/usr/local/include
  9. FLIBS=-L/usr/local/Cellar/gcc/13.1.0/lib/gcc/13/gcc/x86_64-apple-darwin21 -L/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/ -lgfortran -lquadmath -lm
  10. CXX1X=$(LOC)/bin/g++-13
  11. CXX98=$(LOC)/bin/g++-13
  12. CXX14=$(LOC)/bin/g++-13
  13. CXX17=$(LOC)/bin/g++-13

Then install data.table from source again:

  1. install.packages(&quot;data.table&quot;, type = &quot;source&quot;)
  2. library(data.table)
  3. #(should get a message like &quot;data.table 1.14.8 using &gt;1 threads&quot;)

Edit 3

Ok! Back to a working toolchain. Next step is to try out different ~/.R/Makevars configurations and see if the tapi file error comers back, or if it finally compiles with openMP as expected:

First, try the 'complete' ~/.R/Makevars that I use (double check the version of gfortran that macrtools installed is "x86_64-apple-darwin20" using ls /usr/local/gfortran/lib/gcc/, otherwise adjust FLIBS to suit):

  1. LOC=/usr/local/gfortran
  2. CC=$(LOC)/bin/gcc -fopenmp
  3. CXX=$(LOC)/bin/g++ -fopenmp
  4. CXX11=$(LOC)/bin/g++ -fopenmp
  5. CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
  6. CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
  7. LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/lib
  8. CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/include
  9. FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin20/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
  10. CXX1X=/usr/local/gfortran/bin/g++
  11. CXX98=/usr/local/gfortran/bin/g++
  12. CXX11=/usr/local/gfortran/bin/g++
  13. CXX14=/usr/local/gfortran/bin/g++
  14. CXX17=/usr/local/gfortran/bin/g++

If that doesn't work, try deleting everything in ~/.R/Makevars and try:

  1. LDFLAGS += -L/usr/local/Cellar/libomp/lib -lomp
  2. CPPFLAGS += -I/usr/local/Cellar/libomp/include -Xclang -fopenmp

In both cases, if you get errors they should be a lot more informative than unsupported tapi file type.

huangapple
  • 本文由 发表于 2023年6月5日 18:28:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76405533.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定