如何在eclipse中调试R包(使用C和c ++代码)? [英] How to debug an R package (with C and c++ code) in eclipse?

查看:561
本文介绍了如何在eclipse中调试R包(使用C和c ++代码)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在visual studio中我们可以使用attach来调试dll。



在eclipse中有任何方法来调试R包的C / C ++代码/ StatET?



这样的:



http://wiki.scilab.org/How%20to%20debug%20an%20external%20source %20code%20linked%20to%20scilab%20with%20Eclipse%20CDT

解决方案

以下步骤适用于Eclipse-


  1. 使用调试信息编译R(3.2)。使用SVN下载源的步骤可以在R安装指南中找到。






  $。/ configure --enable-R-shlib --with-valgrind-instrumentation = 2 --with-system-valgrind-headers --CFLAGS =' -  g -O0 -fPIC'FFLAGS = '-g -O0 -fPIC'CXXFLAGS =' -  g -O0 -fPIC'FCFLAGS =' -  g -O0 -fPIC'
$ make
$ sudo make install



这将在 / usr / local / lib / R



注意:需要使用-g和-O来添加调试符号并确保comiple防止调试。


  1. 使用C源代码为R-package设置正确的目录结构。使用makefile而不是依赖Eclipse-StatET来构建项目。使安装更容易移植到Windows。


  2. R CMD在命令行安装或使用Makefile会将软件包安装到用户的本地R库。


  3. 在Eclipse(Luna)下,在C / C ++应用程序下创建一个新调试配置。


  4. 在主要标签下:


a。选择一个C / C ++应用程序:



/ usr / local / lib / R / bin / exec / R / p>

b。项目可能指向R-package项目。



c。


  1. 在参数标签下使用:

- slave --vanilla --no-save


  1. 在环境标签下添加:

a。 LD_LIBRARY_PATH:/ use / local / lib / R / lib



b。 R_HOME / usr / local / lib / R
选择将环境附加到本机环境


    < Debugger标签

a。选择GDB调试器 gdb



b。如果GDB命令集未显示为选项,请单击底部的选择其他...。选择Legacy创建流程启动器。这样做现在将显示选择GDB命令集的选项:使用协议 mi 选择标准。


  1. 在来源标签下

使用R source(可选)为R目录添加绝对路径〜/ Downloads / R



b。


  1. 点击Debug。


In visual studio we can use attach to process in order to debug the dlls.

Is there any way to debug C/C++ code of an R package in eclipse/StatET?

Something like this:

http://wiki.scilab.org/How%20to%20debug%20an%20external%20source%20code%20linked%20to%20scilab%20with%20Eclipse%20CDT

解决方案

The following steps work for Eclipse-CDT C/C++ (LUNA).

  1. Compile R (3.2) with debug information. Steps for downloading source using SVN can be found in R install guide.


$./configure --enable-R-shlib --with-valgrind-instrumentation=2 --with-system-valgrind-headers --CFLAGS='-g -O0 -fPIC' FFLAGS='-g -O0 -fPIC' CXXFLAGS='-g -O0 -fPIC' FCFLAGS='-g -O0 -fPIC' 
$make
$sudo make install 

This will install R under /usr/local/lib/R.

Note: -g and -O are needed to add debug symbols and to make sure that comiple optimization do not prevent debugging.

  1. Setup proper directory structure for an R-package with C source code. Use a makefile rather than relying on Eclipse-StatET for building the project. Makes the setup more easily portable to Windows.

  2. R CMD install at the command line or using the Makefile will install the package to the user's local R library.

  3. Under Eclipse (Luna) create a "New Debug Configuration" under C/C++ Application.

  4. Under 'Main' tab:

a. select a C/C++ Application:

/usr/local/lib/R/bin/exec/R

b. Project may point to the R-package project.

c. Check "Connect process input & output to a terminal".

  1. Under "Arguments" tab use:

--slave --vanilla --no-save

  1. Under 'Environment' tab add:

a. LD_LIBRARY_PATH: /use/local/lib/R/lib

b. R_HOME /usr/local/lib/R Select "Append environment to native environment"

  1. Under "Debugger" tab

a. Pick GDB debugger gdb

b. If 'GDB command set' is not displayed as an option, click 'Select other...' at the very bottom. Choose 'Legacy Create Process Launcher'. Doing so will now display options for picking GDB command set: Pick Standard with protocol mi.

  1. Under "source" tab

a. Add absolute path to the R directory with R source (optional) ~/Downloads/R

b. Add absolute path to the package src directory and any other dependent libraries.

  1. Click Debug.

这篇关于如何在eclipse中调试R包(使用C和c ++代码)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆