I managed to use the same laptop Mac pro 14 to run Rcpp a couple months ago. Due to some reason I have to erase everything from the Laptop and reinstall. But after following the instruction in this websitewhich worked for me last time, I still got the following error when sourcing a Cpp file in Rstudio.
The previous question I askedhere
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1'
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_2.so] Error 1
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include" -I"/Users/yanghongguo/Desktop" -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c helloworld.cpp -o helloworld.o
clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o sourceCpp_2.so helloworld.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lquadmath -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp("~/Desktop/helloworld.cpp") :
Error 1 occurred building shared library.
I tried to manually link to /opt/R/arm64/bin by
sudo ln -s /usr/local//gfortran/bin/gfortran /opt/R/arm64/bin
doesn't work.
I redo every step several times and installed different versions of Xcode but nothing work this time, so upset! Please help me with this issue.