我需要重新编译一些旧函数才能再次使用r(早在2016年我就没问题了)。这是命令和错误消息:
long double
system("R CMD SHLIB rk4_mod_r.f90 derive_rossler.f90 simulate_rk4.f90 -o simulate_rossler_rk4.so");
gfortran -arch x86_64 -fPIC -g -O2 -c rk4_mod_r.f90 -o rk4_mod_r.o
gfortran -arch x86_64 -fPIC -g -O2 -c derive_rossler.f90 -o derive_rossler.o
gfortran -arch x86_64 -fPIC -g -O2 -c simulate_rk4.f90 -o simulate_rk4.o
gfortran -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/clang4/lib -o simulate_rossler_rk4.so rk4_mod_r.o derive_rossler.o simulate_rk4.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: framework not found CoreFoundation
collect2: error: ld returned 1 exit status
make: *** [simulate_rossler_rk4.so] Error 1
如下
~.R/Makevars
我注意到VER=-8
CC=gcc$(VER)
CXX=g++$(VER)
CXX11=g++$(VER)
CXX14=g++$(VER)
CXX17=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/8.3.0/lib/gcc/8
在那儿。我不确定这是否正确。我尝试将相同的命令替换为-L/usr/local/clang4/lib
,但无济于事。
我想念什么?
非常感谢,
Ed
答案 0 :(得分:1)
正如我发现的,您的答案在 this thread 中。
说明:
这很有挑战性,但以下是我在 MacOS Big Sur
上使用从源代码编译 R 包的步骤:
重新安装 Xcode Command Line Tools
(不要相信 Software Update
,如果它说它是“最新的”,那是骗人的!- 就我而言,brew doctor
说我的版本实际上是旧的)
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
通过 gcc
安装 llvm
和 Homebrew
(安装 Homebrew
的说明),或者,如果您已经有 gcc
/{{1} } 安装完毕,跳到下一步
llvm
如果您已经通过 # WARNING: This can take several hours
brew install gcc
brew install llvm
安装了 gcc
和 llvm
:
Homebrew
将一些标题链接到 brew cleanup
brew update
brew upgrade
brew reinstall gcc
brew reinstall llvm
/usr/local/include
编辑您的 sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
# I believe you can safely ignore warnings like this:
#ln: /usr/local/include//tcl.h: File exists
#ln: /usr/local/include//tclDecls.h: File exists
#ln: /usr/local/include//tclPlatDecls.h: File exists
#ln: /usr/local/include//tclTomMath.h: File exists
#ln: /usr/local/include//tclTomMathDecls.h: File exists
#ln: /usr/local/include//tk.h: File exists
#ln: /usr/local/include//tkDecls.h: File exists
#ln: /usr/local/include//tkPlatDecls.h: File exists
文件(如果您的 ~/.R/Makevars
目录中没有名为 Makevars
的文件,请创建它)并仅包含以下几行:
~/.R/
从 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++
LLVM_LOC = /usr/local/opt/llvm
CC=/usr/local/gfortran/bin/gcc -fopenmp
CXX=/usr/local/gfortran/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/usr/local/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
中的源代码编译包
R/Rstudio