首页 > 解决方案 > R 3.6.1 配置中缺少“-fdebug-prefix-map”

问题描述

我想使用 调试基于 Rcpp 的包gdb,但我的 R 配置丢失-fdebug-prefix-map,这似乎是调试器无法找到错误行的原因。如何配置此选项?

# etc/Makeconf.  Generated from Makeconf.in by configure.
#
# ${R_HOME}/etc/Makeconf
#
# R was configured using the following call
# (not including env. vars and site configuration)
# configure  '--prefix=/usr' '--with-cairo' '--with-jpeglib' '--with-readline' '--with-tcltk' '--with-system-bzlib' '--with-system-pcre' '--with-system-zlib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share/R/share' '--includedir=/usr/share/R/include' '--with-blas' '--with-lapack' '--enable-R-profiling' '--enable-R-shlib' '--enable-memory-profiling' '--without-recommended-packages' '--build' 'x86_64-linux-gnu' 'build_alias=x86_64-linux-gnu' 'R_PRINTCMD=/usr/bin/lpr' 'R_PAPERSIZE=letter' 'TAR=/bin/tar' 'R_BROWSER=xdg-open' 'LIBnn=lib' 'JAVA_HOME=/usr/lib/jvm/default-java' 'R_SHELL=/bin/bash' 'CC=gcc -std=gnu99' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro' 'CPPFLAGS=' 'FC=gfortran' 'FCFLAGS=-g -O2 -fstack-protector-strong' 'CXX=g++' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g'

这是我的包编译消息。

g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG  -I"/home/sasa/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include"  -ggdb3 -Og -march=native -flto -Wall -Werror -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c train.cpp -o train.o
g++ -std=gnu++17 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o fast.beta.train.so RcppExports.o train.o -ggdb3 -Og -march=native -flto -Wall -Werror -L/usr/lib/R/lib -lR```

标签: rgdbrcpp

解决方案


你可以

  • 编辑~/.R/Makevars(可能是首选)或
  • 编辑MakeconfR 自己的文件etc/(如下$RHOME)或
  • “对于未发布的包”src/Makevars直接编辑

设置这个。没有编程方式,Policy 不鼓励您将其添加到每个包文件中,因此您不能在 CRAN 包中执行第三个选项。


推荐阅读