为什么安装OpenMP后rxode2无法构建模型

tsm1rwdh  于 2023-06-27  发布在  其他
关注(0)|答案(2)|浏览(128)

编辑4(2023/06/22)

我正在尝试使用rxode2包创建PK模型。不幸的是,我在使用rxode({...})函数时得到了一条错误消息,说明error building model。由于我使用的是Mac(OS版本12.6.6,Intel处理器),我按照这里和这里的说明操作,因为我在加载软件包后看到了rxode2 has not detected OpenMP support and will run in single-threaded mode的消息。
最后,这是我所做的(为了复制):
1.重新安装Xcode命令行工具

sudo rm -rf /Library/Developer/CommandLineTools  
sudo xcode-select --install

但是,这也会导致安装较旧的sdk版本。我不知道这是否与过去使用的Xcode有关。我已经重新安装了Xcode,但我仍然有我的旧项目显示在Xcode启动,这些可能是针对以前的SDK版本。我不知道如何执行一个完整的删除(不仅是Xcode,但也有任何设置/配置文件,可以链接到sdk资源在我的电脑某处)。

1.检查libomp

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

1.更新Makevar文件:
注解(1):我第一次在我的工作R目录中创建这个文件(一个使用textedit并删除. txt扩展名的简单txt文件)时犯了一个错误。然后,我在位于我的$HOME (/Users/username/.r/Makevars)中的. r文件夹中(我希望是好位置...)创建了它
注解(2):R找不到gfortran。/usr/local/bin/gfortran是一个符号链接,因为ls -l /usr/local/bin/gfortran打印/usr/local/bin/gfortran -> ../Cellar/gcc/13.1.0/bin/gfortran。然后我相应地修改了Makevar。目前,Makevar文件看起来像这样:

LOC=/usr/local/Cellar/gcc/13.1.0
CC=$(LOC)/bin/gcc-13 -fopenmp
CXX=$(LOC)/bin/g++-13 -fopenmp
CXX11=$(LOC)/bin/g++-13 -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/Cellar/gcc/13.1.0/lib/gcc/current/
CPPFLAGS=-I$(LOC)/include -I/usr/local/include

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
CXX1X=$(LOC)/bin/g++-13
CXX98=$(LOC)/bin/g++-13
CXX14=$(LOC)/bin/g++-13
CXX17=$(LOC)/bin/g++-13

1.从源代码安装**data.table包**,查看是否有问题。
除了许多警告(*-pedantic * flag enabled),我得到以下错误(正如我们所看到的,它使用MacOSX12.sdk,即使最后可用的版本是MacOSX13.1.sdk,cf上图):
install.packages("data.table", type = "source")

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

1.* * 重新排序$PATH**
正如this post中所指出的,当'$HOME/anaconda3/bin/ld'路径位于'$HOME/usr/bin'之前时,使用错误的ld command可能会导致“tapi文件”问题。
由于which -a ld返回Users/username/anaconda3/bin/ld(我激活了Anaconda),所以我在$HOME中的.bash_profile文件的末尾添加了export PATH=/usr/bin:$PATH,然后在终端中运行source ~\.bash_profile以使其生效。

*. bash_profile * file

export JAVA_HOME=$(/usr/libexec/java_home)

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/username/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/username/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/username/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/username/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

export PATH=/usr/bin:$PATH
    • 现在**
$ which -a ld
/usr/bin/ld # it is now preceding $HOME/anaconda3/bin/ld
/Users/username/anaconda3/bin/ld
/usr/bin/ld

但是install.packages("data.table", type = "source")仍然返回

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

1.* * 删除旧版SDK文件**
删除MacOSX11 * 和MacOSX12 *. sdk文件后:

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

ld: library not found for -lz

难道是系统专门找MacOSX12.sdk?删除后,它无法针对最新的sdk文件。sdk和MacOSX13.sdk是指向MacOSX13.1.sdk的 * 符号链接 *

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

我试着谷歌相关问题,我发现this post看起来像Xcode和SDK版本需要密切相关。也许这个问题会出现,因为使用的MacOS SDK版本是MacOSX12?你知道为什么MacOSX. sdk/MacOSX13. . sdk不能被攻击吗?
1.
* 使用macrtools**
我安装了macrtools R package from GitHub的开发版本(因为它已经取代了r-macos-rtools installer package)。删除包含所有MacOSX *. sdk文件的命令行工具文件夹后,我按照以下说明操作:

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

但随后出现了两个新元素:
i)与xcode-select --install相比,macrtools::macos_rtools_install()只安装MacOSX12和MacOSX13 sdk文件(不安装MacOSX11)。

(二)然而:

macrtools::is_xcode_cli_installed()
# FALSE

它说Xcode CLI没有安装(即使SDK文件现在存在)。在尝试专门安装Xcode CLI后也会发生同样的事情:

macrtools::xcode_cli_install()
# Finding available software
# Downloading Command Line Tools for Xcode
# Downloaded Command Line Tools for Xcode
# Installing Command Line Tools for Xcode
# Done with Command Line Tools for Xcode
# Done.

macrtools::is_xcode_cli_installed()
# FALSE
macrtools::is_gfortran_installed()
# TRUE
macrtools::recipes_binary_install('r-base-dev')
# No error
install.packages("data.table", type = "source")
# ** R
# ** inst
# ** byte-compile and prepare package for lazy loading
# ** help
# *** installing help indices
# ** building package indices
# ** installing vignettes
# ** 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 (data.table)

我没有收到消息错误unsupported tapi file type了:).但仍然未检测到OpenMP

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

1.* * 运行{rxode2}**
现在可以构建PK模型而不会出错。然而,许多类似的警告出现了(因为Makevar中的 *-pedantic flag *?),我想知道它们是否与OpenMP未检测有关:

ppk_mode = rxode({
  centr(0) = 0;
  TVCl  = THETA_Cl*(CLCREAT/120)^0.8*(0.7^DIAL);
  TVVc  = THETA_Vc*(WT/70)          *(0.5^DIAL);
  TVVp  = THETA_Vp;
  ...
})

# /usr/local/include/stdlib.h:291:20: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
# int      cgetnext(char **, char **);
#                       ^
# /usr/local/include/stdlib.h:291:20: note: insert '_Nullable' if the pointer may be null
# int      cgetnext(char **, char **);
#                       ^
#                        _Nullable
# /usr/local/include/stdlib.h:291:20: note: insert '_Nonnull' if the pointer should never be null
# int      cgetnext(char **, char **);

# And many other similar warnings.

1.* * gfortran重新安装和Makevar更新**
卸载并使用{macrtools}重新安装gfortran后,它仍然位于相同的位置/usr/local/Cellar/gcc/13.1.0/..

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

然后呢

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

此外,在终端中运行set会打印x86_64-apple-darwin21,这与R中sessionInfo()提到的显示x86_64-apple-darwin20的平台不同。我不知道{macrtools}最后做了什么。
这是当前Makevar文件的样子:

LOC=/usr/local/Cellar/gcc/13.1.0
CC=$(LOC)/bin/gcc-13 -fopenmp
CXX=$(LOC)/bin/g++-13 -fopenmp
CXX11=$(LOC)/bin/g++-13 -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/Cellar/gcc/13.1.0/lib/gcc/current/
CPPFLAGS=-I$(LOC)/include -I/usr/local/include

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
CXX1X=$(LOC)/bin/g++-13
CXX11=/usr/local/gfortran/bin/g++
CXX98=$(LOC)/bin/g++-13
CXX14=$(LOC)/bin/g++-13
CXX17=$(LOC)/bin/g++-13

不幸的是,我再次得到了使用MacOSX12.sdk的tapi错误:
install.packages("data.table", type = "source")

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

我遵循了与之前相同的{macrtools}指令,但这次无法摆脱tapi错误消息和MacOSX12.sdk问题。在这个{macrtools}过程中,我注意到它从'www.example.com'下载了darwin20文件夹中的资源(参见下文)mac.R-project.org ' (cf below)

Downloading Command Line Tools for Xcode
Downloaded Command Line Tools for Xcode
Installing Command Line Tools for Xcode
Done with Command Line Tools for Xcode
Done.
gfortran was already installed! ...
Downloading https://mac.R-project.org/bin/REPOS ...
Using repository  https://mac.R-project.org/bin/darwin20/x86_64 ...
Downloading index  https://mac.R-project.org/bin/darwin20/x86_64/PACKAGES ...
Downloading binary:  https://mac.R-project.org/bin/darwin20/x86_64/xz-5.4.2-darwin.20-x86_64.tar.xz ...
trying URL 'https://mac.R-project.org/bin/darwin20/x86_64/xz-5.4.2-darwin.20-x86_64.tar.xz'
Content type 'application/octet-stream' length 559568 bytes (546 KB)
==================================================
downloaded 546 KB

Installing: xz-5.4.2-darwin.20-x86_64.tar.xz into '/opt/R/x86_64' ...
...

由于我无法解释的原因,用macrtools复制相同的步骤现在再次导致tapi错误。这是否与达尔文版本的差异有关?
值得注意的是,几天前我将MacOS升级到了Monterey。我也重新安装了XQuartz。有没有一种方法可以摆脱所有这些gfortran/gcc,命令行工具和SDK相关的问题,用一个干净的R/Fortan/SDK/etc从头开始。环境?
1.* * 额外信息-SessionInfo()**

它显示使用了 x86_64-apple-darwin 20平台版本(而不是安装在我电脑上的***darwin 21***,这是Makevar中的版本)。但是在Makevar中将21改为20似乎没有影响。
1.清洁和重新开始
由于事情看起来很复杂,我卸载了libomplightgbmllvmXcode command line toolsanaconda

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

关于Anaconda清洁,我按照说明here

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

我也在~/.bash_profile中删除了这个

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

现在,bash_profile看起来像这样:

export JAVA_HOME=$(/usr/libexec/java_home)

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
$PATH
-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

然而,我注意到除了在~/anaconda3中有anaconda 3文件外,我还在/opt/anaconda3中发现了它们,如bash_profile中所述,沿着gfortran(以及其他):

我还发现libomp.dylib/opt/anaconda3/lib中:

这是奇怪的还是预期的?我是否还应该从该文件夹中删除anaconda3

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

最后

rm -rf /Library/Developer/CommandLineTools
xcode-select --install

现在,我重新安装了一些东西,并按照herehere的以下说明进行操作:

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

解包后,我确实找到了这些文件:

/usr/local/lib/libomp.dylib
/usr/local/include/ompt.h
/usr/local/include/omp.h
/usr/local/include/omp-tools.h

我在$HOME/.R/Makevars中添加了以下行,现在只包含以下行:

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

按照here的建议(第6项),我创建并编译了omp_test.c,然后从R调用编译后的C函数,得到:

OpenMP threads available: 8

1.使用data.table和rxode 2进行测试
在对OpenMP似乎可以工作感到非常兴奋之后,我检查了data.tablerxode2

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

我越来越有信心,于是尝试使用rxode2。不过……

install.packages("rxode2", type = "source")
[...]
using C compiler: ‘Apple clang version 14.0.0 (clang-1400.0.29.202)’
using Fortran compiler: ‘GNU Fortran (GCC) 12.2.0’
using C++ compiler: ‘Apple clang version 14.0.0 (clang-1400.0.29.202)’
**using SDK: ‘MacOSX13.1.sdk’ ----> which was empty previously, this is good news!**

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:642:26: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:642:60: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                                                           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:18: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:50: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                                                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:648:17: error: no template named 'numeric_limits'
  static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:651:25: error: no template named 'numeric_limits'
  return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:651:58: error: no template named 'numeric_limits'
  return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
                                                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:661:16: error: no template named 'numeric_limits'
  using _Lim = numeric_limits<_IntT>;
               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:664:12: error: use of undeclared identifier '_Lim'
    return _Lim::max();
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:665:21: error: use of undeclared identifier '_Lim'
  } else if (__r <= _Lim::lowest()) {
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:666:12: error: use of undeclared identifier '_Lim'
    return _Lim::min();

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstdlib:138:9: error: target of using declaration conflicts with declaration already in scope
using ::abs _LIBCPP_USING_IF_EXISTS;
        ^
/usr/local/include/stdlib.h:132:6: note: target of using declaration
int      abs(int) __pure2;
         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: conflicting declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from RcppExports.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:853:1: error: declaration conflicts with target of using declaration already in scope
abs(const complex<_Tp>& __c)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: target of using declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:9: note: using declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
        ^
In file included from RcppExports.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:910:16: error: reference to unresolved using declaration
        return abs(__c.real());
               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from RcppExports.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:912:16: error: reference to unresolved using declaration
        return abs(__c.imag());
               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from RcppExports.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:969:16: error: reference to unresolved using declaration
        __re = abs(__re);
               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from RcppExports.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:1022:29: error: reference to unresolved using declaration
    return complex<_Tp>(log(abs(__x)), arg(__x));
                            ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from RcppExports.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:1049:23: error: reference to unresolved using declaration
    return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from RcppExports.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include/RcppArmadillo/interface/RcppArmadilloForward.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:65:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:1174:33: error: reference to unresolved using declaration
            return complex<_Tp>(abs(__x.real()), __x.imag());
                                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘rxode2’

不幸的是,在尝试安装rxode2时似乎缺少了一些东西。我忘记重新安装任何东西了吗?我还发现了here的一些问题,这些问题与CMAKE_OSX_SYSROOT的错误值有关,并听说了要链接到usr/local/include的头文件。或者是~/.R/Makevars中缺少的东西?我真的不知道下一步该怎么办。

wqsoz72f

wqsoz72f1#

你试过这个吗
https://github.com/nlmixr2/nlmixr2/discussions/26
另外,我认为约翰可能有一些提示,如果你张贴在线程那里。

rbpvctlc

rbpvctlc2#

原始答案:

感谢您提供额外的细节!我有一些想法。
首先,如果在终端中(在终端应用程序中,或在Rstudio的终端选项卡中)运行which gfortran命令,是否会得到输出:“/usr/local/bin/gfortran”?还是别的什么?
如果你得到“/usr/local/bin/gfortran”,并且目录“/usr/local/gfortran”存在(即in the terminal cd /usr/local/gfortran; ls prints“bin include lib libexec share”),删除~.R/Makevar中的所有内容,只包含以下行:

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++

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

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/Makevar修改为以下内容,我相信它会解决你的问题:

LOC=/usr/local/Cellar/gcc/13.1.0/
CC=$(LOC)/bin/gcc-13 -fopenmp
CXX=$(LOC)/bin/g++-13 -fopenmp
CXX11=$(LOC)/bin/g++-13 -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/Cellar/gcc/13.1.0/lib/gcc/current/
CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/include

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
CXX1X=$(LOC)/bin/g++-13
CXX98=$(LOC)/bin/g++-13
CXX14=$(LOC)/bin/g++-13
CXX17=$(LOC)/bin/g++-13

然后再次从源代码安装data.table,看看它是否使用openMP构建:
install.packages(“data.table”,type =“source”)library(data.table)#(应该会得到类似“data.table 1.14.8 using >1 threads”的消息)我希望这能起作用,但如果不行,下一步就是检查是否安装了openMP,并且可以被编译器定位。

编辑2

OpenMP显然已经安装好了,但是我无法重现SDK版本与命令行工具的问题,所以我很难解决这个问题。关于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't support unnamed structs/unions [-Wpedantic]警告,这些不是错误,它们是在使用-pedantic标志时打印的;你可以忽略它们。
如果您在Makevar文件中删除对SDK的引用,是否仍然会出现“tapi file”错误?即,将Makevar更改为以下内容:

LOC=/usr/local/Cellar/gcc/13.1.0/
CC=$(LOC)/bin/gcc-13 -fopenmp
CXX=$(LOC)/bin/g++-13 -fopenmp
CXX11=$(LOC)/bin/g++-13 -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/Cellar/gcc/13.1.0/lib/gcc/current/
CPPFLAGS=-I$(LOC)/include -I/usr/local/include

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
CXX1X=$(LOC)/bin/g++-13
CXX98=$(LOC)/bin/g++-13
CXX14=$(LOC)/bin/g++-13
CXX17=$(LOC)/bin/g++-13

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

install.packages("data.table", type = "source")
library(data.table)
#(should get a message like "data.table 1.14.8 using >1 threads")

编辑3

好吧!回到一个工作的工具链。下一步是尝试不同的~/.R/Makevars配置,看看tapi file错误是否又出现了,或者它最终是否按预期使用openMP编译:
首先,尝试我使用的'complete' ~/.R/Makevars(使用ls /usr/local/gfortran/lib/gcc/仔细检查macrtools安装的gfortran版本是否为“x86_64-apple-darwin 20”,否则调整FLIBS以适应):

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-darwin20/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++

如果这不起作用,请尝试删除~/.R/Makevars中的所有内容并尝试:

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

在这两种情况下,如果您得到错误,它们应该比unsupported tapi file type提供更多信息。

相关问题