Trying to compile R Package RSAP - r

I'm trying to compile the R Package RSAP using the command
R CMD INSTALL RSAP
The necessary SAP library SAP NW RFCSDK is located in C:\nwrfcsdk.
I'm building on Windows 10 64
R version 3.4 32 bit (I tired 64 as well)
R tools with mingw32
It does not compile but terminates with the following errors:
c:/Rtools/mingw_32/bin/gcc -shared -s -static-libgcc -o RSAP.dll tmp.def RSAP.o -L. -LC:/nwrfcsdk/lib -lsapnwrfc -llibsapucum -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.0/bin/i386 -lR
RSAP.o:RSAP.c:(.text+0x4b): undefined reference to `RfcPing#8'
RSAP.o:RSAP.c:(.text+0x23a): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x2d5): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x369): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x3ef): undefined reference to `RfcSAPUCToUTF8#24'
RSAP.o:RSAP.c:(.text+0x4b8): undefined reference to `RfcSAPUCToUTF8#24'
RSAP.o:RSAP.c:(.text+0x645): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x6e3): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x719): undefined reference to `RfcOpenConnection#12'
RSAP.o:RSAP.c:(.text+0x923): undefined reference to `RfcCloseConnection#8'
...
and so on until it stops with
collect2.exe: error: ld returned 1 exit status
keine DLL erzeugt
ERROR: compilation failed for package 'RSAP'
* removing 'C:/Users/jmueller/R/win-library/3.4/RSAP'
* restoring previous 'C:/Users/jmueller/R/win-library/3.4/RSAP'
What am I doing wrong? Any help is highly appreciated!

This is what happens when you try to build RSAP in the 32-bit environment of R using the 64-bit version of the SAP NW RFC SDK. I had the same problem and after executing the following command in the 64-bit environment of RGui (with the 64-bit version of SAP NW RFC SDK located in C:\nwrfcsdk) the undefined references were gone.
Command:
install.packages('RSAP', repos=c('http://piersharding.com/R'), type="source", configure.args=c('--with-nwrfcsdk-include=C:/nwrfcsdk/include --with-nwrfcsdk-lib=C:/nwrfcsdk/lib'))
as described in:
https://github.com/piersharding/RSAP/blob/master/INSTALL

Related

R: Error installing GWmodel package from source in R-4.1.1

I am trying to install the package GWmodel from source following this website. After running install_github(lbb220/GWmodel/GWmodel) I am receiving this error: Error: Failed to install 'unknown package' from GitHub: Line starting '<<<<<<< HEAD ...' is malformed!
The reason I want to to install the package from source and not use the install.packages("GWmodel") is that I want to use parallel.method = "cuda". In the documentation it says:
Requirements of using CUDA for high-performence computation in GWR functions:
To run GWR-CUDA (i.e. parallel.method is pecified as “cuda”) with gwr.basic , bw.gwr and gwr.model.selection, the following conditions are required:
There is at least one NVIDIA GPU supporting CUDA equipped on user's computer.
CUDA (>10.2) are installed with the environment variable 'CUDA_HOME' set properly.
The package should re-built from source. - For Linux user, 'GWmodelCUDA' will be automatically built if CUDA toolkit could be detected by the complier. - For Windows user, 'GWmodelCUDA.dll' and 'GWmodelCUDA.lib' will be automatically downloaded; however, we would recommend users to build the 'GWmodelCUDA' library manually to avoid some potentially unknown issues, and an 'CMakeLists.txt' file is provided for this procedure.
If any condition above is not satisfied, the GWR-CUDA will not work even though the “parallel.method” is specified as “cuda”.
If I install it using install.github() I am getting the error I mentioned. I have installed the CUDA (>10.2) and I have set the environment variable 'CUDA_HOME' properly.
If I use the install.packages("GWmodel") I get no errors. I also tried to download GWmodel.zip and install from a local zip file, but the same error.
I have install rtools successfully (I tested it using the example here)
I am using R.Studio 1.4.1717, R 4.1.1 and Windows 11.
Any ideas how can I proceed?
I used install_github("lbb220/GWmodel") and although I don't receive the above error, still the installation cannot be done. I am getting the below message now:
** libs
*** arch - i386
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-41~1.1/include" -DNDEBUG -I'C:/Program Files/R/R-4.1.1/library/Rcpp/include' -I'C:/Program Files/R/R-4.1.1/library/RcppArmadillo/include' -ARMA_64BIT_WORD=1 -fopenmp -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c GWmodel.cpp -o GWmodel.o
GWmodel.cpp: In function 'double sp_gcdist(double, double, double, double)':
GWmodel.cpp:764:29: error: 'DOUBLE_EPS' was not declared in this scope
if (fabs(lat1 - lat2) < DOUBLE_EPS) {
^~~~~~~~~~
GWmodel.cpp:764:29: note: suggested alternative: 'ENABLE_NLS'
if (fabs(lat1 - lat2) < DOUBLE_EPS) {
^~~~~~~~~~
ENABLE_NLS
GWmodel.cpp: In function 'void printMat(arma::mat)':
GWmodel.cpp:1165:16: warning: comparison of integer expressions of different signedness: 'const uword' {aka 'const unsigned int'} and 'int' [-Wsign-compare]
if (m.n_rows < n)
~~~~~~~~~^~~
make: *** [C:/PROGRA~1/R/R-41~1.1/etc/i386/Makeconf:245: GWmodel.o] Error 1
ERROR: compilation failed for package 'GWmodel'
* removing 'C:/Program Files/R/R-4.1.1/library/GWmodel'
Warning message:
In i.p(...) :
installation of package ‘C:/Users/GEOGRA~1/AppData/Local/Temp/RtmpOwWBPs/file8f43609514d/GWmodel_2.2-0.tar.gz’ had non-zero exit status
This is because you are not actually installing from the main repository. Try install_github(lbb220/GWmodel).

HDF5 package error compile

I have compiled the HDF5 package by GCC 4.9.2, CentOS 6.8 and std=c++11, but I get error:
for package Linux 3.10 CentOS 7 x86_64 I get :
./host/src/hdf5/lib/libhdf5.so: undefined reference to `memcpy#GLIBC_2.14'
collect2: error: ld returned 1 exit status
for package Linux 2.6 CentOS 6 x86_64 I get :
/opt/rh/devtoolset-3/root/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/ld: warning: libsz.so.2, needed by ./host/src/hdf5/lib/libhdf5.so, not found (try using -rpath or -rpath-link)
./host/src/hdf5/lib/libhdf5.so: undefined reference to `SZ_encoder_enabled'
./host/src/hdf5/lib/libhdf5.so: undefined reference to `SZ_BufftoBuffCompress'
./host/src/hdf5/lib/libhdf5.so: undefined reference to `SZ_BufftoBuffDecompress'
collect2: error: ld returned 1 exit status
Any idea to slove this?
Thank you
The compiler complains that it is not finding SZ_... routines. szip is an optional library for HDF5 that you have to download separately.
Two options:
Re-configure hdf5 to disable szip
download, build and install szip

Can't install rPython package in R

I'm using CentOS 6.4 and I'm trying to install the R package 'rPython'. It failed with following messages. Anybody knows how to fix this? Thanks!
/usr/bin/ld: /usr/local/lib/python2.7/config/libpython2.7.a(dictobject.o): relocation R_X86_64_32S against `PyDict_Type' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/python2.7/config/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [rPython.so] Error 1
ERROR: compilation failed for package ‘rPython’
* removing ‘/usr/lib64/R/library/rPython’
It seems that the default installation of Python on RHEL / CentOS,
etc. is not "shared enabled", i.e., it does not include libpython*.so. Just the libpython*.a static library. This prevents some Python
applications to run properly. There are instructions in different
places, (e.g., here or here) indicating how to install Python as a shared library on CentOS and related Linux flavours.

Library of opencl not found?

I am trying to compile an opencl sample code but I am getting the following error
/usr/bin/ld: cannot find -lOpenCL
/usr/bin/ld: cannot find -loclUtil_x86_64
/usr/bin/ld: cannot find -lshrutil_x86_64
collect2: error: ld returned 1 exit status
make: *** [../../..//OpenCL//bin//linux/release/DeviceQuery] Error 1
I am using intel based machine ...
My make file is
EXECUTABLE := DeviceQuery
CCFILES := devQury.cpp
include ../common/common_opencl.mk
Any help would be of great help
Thanks ,
Piyush
Make sure that the OpenCL library (libOpenCL.so) is present in /usr/lib. This should have been put in place by the driver, so you shouldn't have to do anything.
If not then copy libOpenCL.so present in your cuda toolkit (lib64) to the above location.
sudo cp /usr/local/cuda-7.0/lib64/libOpenCL.so /usr/lib
This fixes the error
/usr/bin/ld: cannot find -lOpenCL
collect2: error: ld returned 1 exit status
Have you installed the OpenCL SDK from either Intel or AMD? If not then perhaps you should follow these instructions. If you have an SDK installed then your makefile is probably missing -L... in the compiler command line, where ... is the path to the lib folder in the OpenCL SDK that should contain a file libOpenCL.a or something similar.

undefined reference errors while compiling a QT program

I just installed QtSDK 1.2 on my redhat enterprise linux 5.6. While compiling a QT program, I got the following errors:
[root#stack example1]# make
g++ -m64 -Wl,-O1 -Wl,-rpath,/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib -o example1 fac1.o -L/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib -lQtGui -lQtCore -lpthread
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to `g_main_context_push_thread_default'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to `inotify_init1#GLIBC_2.9'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to `pipe2#GLIBC_2.9'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to `g_main_context_pop_thread_default'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to `FcFreeTypeQueryFace'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to `FT_Library_SetLcdFilter'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to `__longjmp_chk#GLIBC_2.11'
collect2: ld returned 1 exit status
make: *** [example1] Error 1
[root#stack example1]#
It seems g++ compiler uses all correct options. Befor I installed QtSDK 1.2 on rhel 5.6, I had copied libstdc++.so.6.0.10 to /usr/lib64 and relinked libstdc++.so.6 to libstdc++.so.6.0.10, since QtSDK requires GLIBCXX_3.4.9 symbols in the libstdc++ library. I think this may be the source of the problem. But I'm not sure about that. So any advice? Thanks in advance.
My answer is multiple questions:
Are you in a 64 architecture? If not why using 64 libraries?
Did the libraries copied are 64 versions ?
If it is the case, why do you need to copy them, there should already be standard libraries in /usr/lib64
If it is not the case the errors are legit.
How did you compiled Qt in the first place? if your Qt libraries are really 64 bits, then it means the environment setup was already correct.

Resources