c++ R Package Error错误:'std::Rf_beta'尚未声明#define beta Rf_beta

im9ewurl  于 2023-08-09  发布在  其他
关注(0)|答案(1)|浏览(83)

我正在尝试安装一个名为dbarts的R包。我在一台rhel 8 linux机器上运行R。但我在安装过程中看到以下错误。
我已经安装了rhel 8 linux包gcc、clang和clang-devel。

> install.packages('dbarts', lib = .Library.site)
trying URL 'https://packagemanager.rstudio.com/cran/2023-07-12/src/contrib/dbarts_0.9-23.tar.gz'
Content type 'binary/octet-stream' length 850972 bytes (831 KB)
==================================================
downloaded 831 KB

* installing *source* package ‘dbarts’ ...
** package ‘dbarts’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
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... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking how to run the C preprocessor... gcc -E
checking whether the compiler supports GNU C++... yes
checking whether g++ -std=gnu++17 accepts -g... yes
checking for g++ -std=gnu++17 option to enable C++11 features... none needed
checking how to run the C++ preprocessor... g++ -std=gnu++17 -E
checking for C/C++ restrict keyword... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for C compiler vendor... gnu
checking whether C compiler accepts ... yes
checking whether C compiler accepts -msse2... yes
checking whether C compiler accepts -msse4.1... yes
checking whether C compiler accepts -mavx... yes
checking whether C compiler accepts -mavx2... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking whether gcc is Clang... no
checking whether pthreads work with "-pthread" and "-lpthread"... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for cstdint... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for malloc.h... yes
checking for int64_t... yes
checking for uint64_t... yes
checking size of size_t... 8
checking alignment of void*... 8
checking for gettimeofday... yes
checking for clock_gettime... yes
checking for ffs... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for working posix_memalign... yes
checking for snprintf... yes
checking if g++ supports namespace std... yes
checking whether snprintf is in std::... yes
checking for log1p... yes
checking whether log1p is in std::... no
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating src/config.hpp
config.status: creating src/dbarts/config.hpp
config.status: creating src/misc/config.h
config.status: creating src/external/config.h
config.status: creating inst/include/dbarts/types.hpp
config.status: creating src/include/misc/types.h
** libs
using C compiler: ‘gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18)’
using C++ compiler: ‘g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18)’
g++ -std=gnu++17 -I"/opt/R/4.3.1/lib/R/include" -DNDEBUG -I../inst/include -Iinclude -pthread  -I/usr/local/include    -fpic  -g -O2  -c R_C_interface.cpp -o R_C_interface.o
g++ -std=gnu++17 -I"/opt/R/4.3.1/lib/R/include" -DNDEBUG -I../inst/include -Iinclude -pthread  -I/usr/local/include    -fpic  -g -O2  -c R_interface.cpp -o R_interface.o
g++ -std=gnu++17 -I"/opt/R/4.3.1/lib/R/include" -DNDEBUG -I../inst/include -Iinclude -pthread  -I/usr/local/include    -fpic  -g -O2  -c R_interface_common.cpp -o R_interface_common.o
g++ -std=gnu++17 -I"/opt/R/4.3.1/lib/R/include" -DNDEBUG -I../inst/include -Iinclude -pthread  -I/usr/local/include    -fpic  -g -O2  -c R_interface_crossvalidate.cpp -o R_interface_crossvalidate.o
In file included from include/external/stats.h:10,
                 from R_interface_crossvalidate.cpp:13:
/opt/R/4.3.1/lib/R/include/Rmath.h:210:15: error: ‘std::Rf_beta’ has not been declared
 #define beta  Rf_beta
               ^~~~~~~
make: *** [/opt/R/4.3.1/lib/R/etc/Makeconf:200: R_interface_crossvalidate.o] Error 1
ERROR: compilation failed for package ‘dbarts’
* removing ‘/opt/R/4.3.1/lib/R/site-library/dbarts’

The downloaded source packages are in
        ‘/opt/rtemp/Rtmpzomc18/downloaded_packages’
Warning message:
In install.packages("dbarts", lib = .Library.site) :
  installation of package ‘dbarts’ had non-zero exit status

字符串

epggiuax

epggiuax1#

我认为您提供的错误消息被切断了,但我知道您在RHEL8 Linux机器上安装'dbarts' R包时遇到了错误。您看到的错误似乎与包的编译过程和'Rf_beta'函数的使用有关。
这个问题可能与'dbarts'包依赖于底层R安装的某些函数有关,并且您看到的错误表明'Rf_beta'函数未被识别或声明。
以下是您可以尝试进行故障排除和解决此问题的几个步骤:
1.检查R版本兼容性:确保您使用的R版本与'dbarts'包兼容。某些软件包可能与特定的R版本存在兼容性问题。
1.检查依赖项:确保您已经安装了'dbarts'包的所有必需依赖项。该软件包可能具有需要安装的某些先决条件。
1.重新安装R包开发工具:尝试重新安装R包开发工具,如r-base-dev和相关包。这些工具是从源代码编译R包所必需的。
1.清洁安装:有时,软件包安装可能会损坏。在这种情况下,如果“dbarts”软件包只安装了一部分,那么卸载它并重新安装可能会有帮助。
1.检查编译标志:包编译过程可能需要某些标志或设置才能正常工作。您可以在安装软件包之前尝试设置环境变量,如CFLAGSCXXFLAGS,以确保正确设置编译器标志。
1.更新R:如果您使用的是旧版本的R,请考虑更新到更新的版本。较新的版本可能有错误修复和改进,可以解决这个问题。
1.联系维护人员:如果以上步骤都不起作用,最好联系'dbarts'包的维护人员。他们可能遇到过类似的问题,可以就如何解决这些问题提供指导。
请记住,在对R环境进行更改时,始终采取备份和预防措施。如果可能的话,您可能还想考虑使用像renv这样的包管理器来管理R项目的依赖项和环境。这可以帮助隔离项目的环境,并避免与系统范围的库发生冲突。

相关问题