在Netbeans中编译使用R库的C代码



我在调试一些我作为R包的一部分编写的C代码时遇到了麻烦。当我从Windows控制台(即cmd.exe)使用R CMD SHLIB时,代码编译和执行:

>R CMD SHLIB MaximumAgreementForest.c
gcc -m64 -I"C:/PROGRA~1/R/R-32~1.4RE/include" -DNDEBUG     -I"d:/RCompile/r-compiling/local/local323/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c MaximumAgreementForest.c -o MaximumAgreementForest.o
gcc -m64 -shared -s -static-libgcc -o MaximumAgreementForest.dll tmp.def MaximumAgreementForest.o -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LC:/PROGRA~1/R/R-32~1.4RE/bin/x64 -lR

脚本也在Netbeans中正确构建,直到我开始使用R库中的R_allocC_alloc函数。现在它似乎不能找到一些特定于r的函数的定义。当我尝试在Netbeans中构建项目时,控制台列出以下内容:

cd 'C:WorkFunimplied_weightMAF'
C:MinGWmsys1.0binmake.exe -f Makefile CONF=Debug
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Work/Fun/implied_weight/MAF'
"/C/MinGW/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/libMAF.dll
make.exe[2]: Entering directory `/c/Work/Fun/implied_weight/MAF'
mkdir -p build/Debug/MinGW-Windows/_ext/5c0
rm -f "build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o.d"
gcc -DDEBUG -O2 -Wall -mtune=core2   -c -g -Wall -I/C/Program Files/R/R-3.2.4revised/include  -MMD -MP -MF "build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o.d" -o build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o ../MaximumAgreementForest.c
mkdir -p dist/Debug/MinGW-Windows
gcc -DDEBUG -O2 -Wall -mtune=core2    -o dist/Debug/MinGW-Windows/libMAF.dll build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o -L/C/Program Files/R -L/C/Program Files/R/R-3.2.4revised/library -shared
build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o: In function `forest_new':
C:WorkFunimplied_weightMAF/../MaximumAgreementForest.c:37: undefined reference to `R_alloc'
build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o: In function `forest_plant':
C:WorkFunimplied_weightMAF/../MaximumAgreementForest.c:55: undefined reference to `S_alloc'
[...]
C:WorkFunimplied_weightMAF/../MaximumAgreementForest.c:515: undefined reference to `R_chk_free'
collect2.exe: error: ld returned 1 exit status
我的脚本,一个。c文件,包含以下行
#define USE_RINTERNALS
#include <R.h> // which itself #includes R_ext/Memory, R_ext Printf
#include <R_ext/Print.h>
#include <R_ext/Memory.h>
#include <Rinternals.h>

认为Netbeans无法指向相关库,我尝试在文件→项目属性→常规→源文件夹添加和删除C:/Program Files/R/R-3.2.4revised/includeC:/Program Files/R/R-3.2.4revised/bin/x64,但没有效果。

File→Project Properties→Build→C compiler下,我包含了C:/Program Files/R/R-3.2.4revised/include .

当我添加C:/Program Files/R/R-3.2.4revised/bin/x64/R.dllBuild→Linker→Libraries→Libraries时,通过 add Library…选项,我收到错误c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lR,链接器退出,没有(之前?)抱怨未定义的引用。

当我随后添加"C:/Program Files/R/R-3.2.4revised/bin/x64/",它已经在系统路径中,到Build→Linker→Additional Library Directories,编译器失败,显示C:/Program Files/R/R-3.2.4revised/bin/x64/R.dll: file not recognized: File format not recognized

我错过了什么?我如何将Netbeans指向相关的R库?

当32位编译器试图加载到64位.dll(反之亦然)时,会遇到File format not recognized错误。改变路径C:/Program Files/R/R-3.2.4revised/bin/x64/R.dllC:/Program Files/R/R-3.2.4revised/bin/i386/R.dll问题解决

相关内容

  • 没有找到相关文章