我正在尝试使用Nvidia卡,R 3.5.1,Rtools35:https://github.com/WhateverLiu/tryOpenCLcppCode在Windows 7下构建包含OpenCL和C ++代码的最小R软件包,但是它不起作用。
但是,构建具有相同结构但仅包含C和OpenCL代码的软件包没有问题:https://github.com/WhateverLiu/tryOpenCLcCodeOnly。打包功能运行完美。
下面是构建两个软件包的编译器日志。
使用C代码成功:
* installing to library 'C:/Program Files/R/R-3.5.1/library'
* installing *source* package 'tryGPU' ...
** libs
C:/RBuildTools/3.5/mingw_64/bin/gcc -I"C:/PROGRA~1/R/R-35~1.1/include" -DNDEBUG -I"C:/Program Files/R/R-3.5.1/library/Rcpp/include" -O2 -Wall -std=gnu99 -mtune=generic -c openclcode.c -o openclcode.o
C:/RBuildTools/3.5/mingw_64/bin/gcc -shared -s -static-libgcc -o tryGPU.dll tmp.def openclcode.o -LC:/Windows/System32 -lOpenCL -LC:/PROGRA~1/R/R-35~1.1/bin/x64 -lR
installing to C:/Program Files/R/R-3.5.1/library/tryGPU/libs/x64
** R
** byte-compile and prepare package for lazy loading
No man pages found in package 'tryGPU'
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (tryGPU)
In R CMD INSTALL
使用C ++代码失败:
* installing to library 'C:/Program Files/R/R-3.5.1/library'
* installing *source* package 'tryGPU' ...
** libs
C:/RBuildTools/3.5/mingw_64/bin/g++ -shared -s -static-libgcc -o tryGPU.dll tmp.def RcppExports.o openclcode.o -LC:/Windows/System32 -lOpenCL -LC:/PROGRA~1/R/R-35~1.1/bin/x64 -lR
d000055.o:(.idata$5+0x0): multiple definition of `__imp___C_specific_handler'
d000052.o:(.idata$5+0x0): first defined here
C:/RBuildTools/3.5/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/libstdc++.a(pure.o):(.text$__cxa_pure_virtual+0x17): undefined reference to `write'
C:/RBuildTools/3.5/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/libstdc++.a(pure.o):(.text$__cxa_deleted_virtual+0x17): undefined reference to `write'
C:/RBuildTools/3.5/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/libstdc++.a(basic_file.o):(.text$_ZN12_GLOBAL__N_1L6xwriteEiPKcx+0x29): undefined reference to `write'
C:/RBuildTools/3.5/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/libstdc++.a(basic_file.o):(.text$_ZNSt12__basic_fileIcE8sys_openEiSt13_Ios_Openmode+0x36): undefined reference to `fdopen'
C:/RBuildTools/3.5/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/libstdc++.a(basic_file.o):(.text$_ZNSt12__basic_fileIcE2fdEv+0x8): undefined reference to `fileno'
C:/RBuildTools/3.5/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/libstdc++.a(basic_file.o):(.text$_ZNSt12__basic_fileIcE6xsgetnEPcx+0x2b): undefined reference to `read'
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'tryGPU'
* removing 'C:/Program Files/R/R-3.5.1/library/tryGPU'
* restoring previous 'C:/Program Files/R/R-3.5.1/library/tryGPU'
In R CMD INSTALL
Exited with status 1.
我认为混合C和C ++代码的方式是正确的(使用extern "C" {}
),但是似乎一旦g++
介入,冲突就会增加,而我对此不太了解。
我尝试使用OpenCL C ++绑定重新实现程序,但是编译器会抛出完全相同的错误。
任何帮助回答问题或为我提供指导的人,将不胜感激!