Building a project under Windows including Rcpp and RInside - r

Here's a compilation problem.
The project works on Linux and OS X and must be ported to Windows. It uses RInside and Rcpp librairies.
To do so, I installed R, Cygwin and RTools and compiled the R librairies. It worked fine.
Now the problem:
The QMake step happens with no error, but the building exits with an error. I get this :
error: [1]: No such file or directory
error: Rcpp:::CxxFlags(): Invalid argument
error: [1]: No such file or directory
error: RInside:::CxxFlags(): Invalid argument
Long version:
17:18:36: Débute : "C:\Qt\Qt5.7.0\Tools\mingw530_32\bin\mingw32-make.exe"
C:/Qt/Qt5.7.0/5.7/mingw53_32/bin/qmake.exe -spec win32-g++ CONFIG+=debug CONFIG+=qml_debug -o Makefile ../IHM/Rpp-IHM.pro
C:/Qt/Qt5.7.0/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/Henri/Desktop/rpp/src/build-Rpp-IHM-Desktop_Qt_5_7_0_MinGW_32bit-Debug'
g++ -c -pipe -fno-keep-inline-dllexport -Wno-unused-parameter -IC:/Progz/R-3.3.2/include -IC:/Progz/R-3.3.2/include/x64 [1] "Rcpp:::CxxFlags()" [1] "RInside:::CxxFlags()" -g -std=gnu++11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../IHM -I. -I../computer/RppUtils -I../computer/RppEngine -IC:/Qt/Qt5.7.0/5.7/mingw53_32/include -IC:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtSvg -IC:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtWidgets -IC:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtGui -IC:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtANGLE -IC:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtCore -Idebug -IC:/Qt/Qt5.7.0/5.7/mingw53_32/mkspecs/win32-g++ -o debug/WrapperRppR.o ../IHM/WrapperRppR.cpp
g++.exe: error: [1]: No such file or directory
g++.exe: error: Rcpp:::CxxFlags(): Invalid argument
g++.exe: error: [1]: No such file or directory
g++.exe: error: RInside:::CxxFlags(): Invalid argument
Makefile.Debug:2914: recipe for target 'debug/WrapperRppR.o' failed
mingw32-make[1]: *** [debug/WrapperRppR.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Users/Henri/Desktop/rpp/src/build-Rpp-IHM-Desktop_Qt_5_7_0_MinGW_32bit-Debug'
Makefile:34: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2
17:18:40: Le processus "C:\Qt\Qt5.7.0\Tools\mingw530_32\bin\mingw32-make.exe" s'est terminé avec le code 2.
Erreur lors de la compilation/déploiement du projet Rpp-IHM (kit : Desktop Qt 5.7.0 MinGW 32bit)
When executing step "Make"
In fact, it seems that it doesn't find RInside.h, in spite of the fact that the R_HOM variable is set to the directory of R (here : C:/Progz/R-3.3.2/).
Here's a part of the .pro file:
QT += core gui svg
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Rpp-IHM
TEMPLATE = app
CONFIG += c++11
CONFIG += -v
## comment this out if you need a different version of R,
## and set set R_HOME accordingly as an environment variable
## R_HOM = $$system($$R_HOME)
win32 {
#A specifier
R_HOM = "C:/Progz/R-3.3.2/"
}
unix:!macx {
# WORKING
R_HOM = "/usr/lib/R/"
}
macx {
# WORKING
R_HOM = "/Library/Frameworks/R.framework/Resources/"
}
## include headers and libraries for R
RCPPFLAGS = $$system($$R_HOM/bin/R CMD config --cppflags)
RLDFLAGS = $$system($$R_HOM/bin/R CMD config --ldflags)
RBLAS = $$system($$R_HOM/bin/R CMD config BLAS_LIBS)
RLAPACK = $$system($$R_HOM/bin/R CMD config LAPACK_LIBS)
## if you need to set an rpath to R itself, also uncomment
RRPATH = -Wl,-rpath,R_HOME/lib
## include headers and libraries for Rcpp interface classes
RCPPINCL = $$system($$R_HOM/bin/Rscript -e \'Rcpp:::CxxFlags\(\)\')
RCPPLIBS = $$system($$R_HOM/bin/Rscript -e \'Rcpp:::LdFlags\(\)\')
## for some reason when building with Qt we get this each time
## so we turn unused parameter warnings off
RCPPWARNING = -Wno-unused-parameter
## include headers and libraries for RInside embedding classes
RINSIDEINCL = $$system($$R_HOM/bin/Rscript -e \'RInside:::CxxFlags\(\)\')
RINSIDELIBS = $$system($$R_HOM/bin/Rscript -e \'RInside:::LdFlags\(\)\')
INCLUDEPATH = ../computer/RppUtils
INCLUDEPATH += ../computer/RppEngine
## compiler etc settings used in default make rules
QMAKE_CXXFLAGS += $$RCPPWARNING $$RCPPFLAGS $$RCPPINCL $$RINSIDEINCL
QMAKE_LFLAGS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RCPPLIBS $$RINSIDELIBS
QMAKE_CXXFLAGS_WARN_OFF += -Wunused-parameter
What did I miss?

Related

__e_acsl_assert is not getting added for all given assert in .i file

I am new to Frama-C. I specifically need to use e-acsl plugin for verification purposes. I used first.i file as
int main(void) {
int x = 0;
/∗# assert x == 0; ∗/
/∗# assert x == 1; ∗/
return 0;
}
Created monitored_first.c file from first.i file using the following command.
$ frama-c -e-acsl first.i -then-last -print -ocode monitored_first.c
The main function inside the monitored_first.c looks like the one below.
int main(void)
{
int __retres;
__e_acsl_memory_init((int *)0,(char ***)0,8UL);
int x = 0;
__retres = 0;
__e_acsl_memory_clean();
return __retres;
}
It is not adding e_acsl assertion for x==1.
I tried it using the "e-acsl-gcc.sh" script , which generated the monitored_first.i file. But the main function inside monitored_first.i is same as that in monitored_first.c.
$ e-acsl-gcc.sh -c -omonitored_first.i first.i
The above command generated two executable, "a.out.e-acsl" and "a.out". It also generates some warnings when run in ubuntu 22.04 as follows:
/home/amrutha/.opam/4.11.1/bin/frama-c -remove-unused-specified-functions -machdep gcc_x86_64 '-cpp-extra-args= -std=c99 -D_DEFAULT_SOURCE -D__NO_CTYPE -D__FC_MACHDEP_X86_64 ' -no-frama-c-stdlib first.i -e-acsl -e-acsl-share=/home/amrutha/.opam/4.11.1/bin/../share/frama-c/e-acsl -then-last -print -ocode monitored_first.i
[kernel] Parsing first.i (no preprocessing)
[e-acsl] beginning translation.
[kernel] Parsing FRAMAC_SHARE/e-acsl/e_acsl.h (with preprocessing)
/tmp/ppannot15ad34.c:362: warning: "__STDC_IEC_60559_BFP__" redefined
362 | #define __STDC_IEC_60559_BFP__ 201404L
|
In file included from <command-line>:
/usr/include/stdc-predef.h:39: note: this is the location of the previous definition
39 | # define __STDC_IEC_60559_BFP__ 201404L
|
/tmp/ppannot15ad34.c:363: warning: "__STDC_IEC_60559_COMPLEX__" redefined
363 | #define __STDC_IEC_60559_COMPLEX__ 201404L
|
In file included from <command-line>:
/usr/include/stdc-predef.h:49: note: this is the location of the previous definition
49 | # define __STDC_IEC_60559_COMPLEX__ 201404L
|
[e-acsl] translation done in project "e-acsl".
+ gcc -std=c99 -m64 -g -O2 -fno-builtin -fno-merge-constants -Wall -Wno-long-long -Wno-attributes -Wno-nonnull -Wno-undef -Wno-unused -Wno-unused-function -Wno-unused-result -Wno-unused-value -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-implicit-function-declaration -Wno-empty-body first.i -o a.out
+ gcc -DE_ACSL_SEGMENT_MMODEL -std=c99 -m64 -g -O2 -fno-builtin -fno-merge-constants -Wall -Wno-long-long -Wno-attributes -Wno-nonnull -Wno-undef -Wno-unused -Wno-unused-function -Wno-unused-result -Wno-unused-value -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-implicit-function-declaration -Wno-empty-body -I/home/amrutha/.opam/4.11.1/bin/../share/frama-c/e-acsl -o a.out.e-acsl monitored_first.i /home/amrutha/.opam/4.11.1/bin/../share/frama-c/e-acsl/e_acsl_rtl.c /home/amrutha/.opam/4.11.1/bin/../lib/frama-c/e-acsl/libeacsl-dlmalloc.a -lgmp -lm
In ubuntu 20.04 there is no any warning, only the end part is getting displayed. When run ./a.out.e-acsl , it simply run the code without any message, which is not supposed. The expected output should look like this:
$ ./a.out.e-acsl
first.i: In function 'main'
first.i:4: Error: Assertion failed:
The failing predicate is:
x == 1.
Aborted (core dumped)
$ echo $?
134
I tried it in ubuntu 22.04 with opam version 2.1.2 and Fragma-C 25.0
and ubuntu 20.04 with opam version 2.0.5 and Fragma-C 25.0
The same issue has been posted to Frama-C's public bug tracking and it seems the cause might have been the non-ASCII asterisk characters used in the ACSL annotations: ∗ instead of *.
I still don't understand how the comments could parse at all (my compiler gives a syntax error), but the user seems to indicate that replacing them solved the problem.
In any case, in similar situations one can either use the Frama-C GUI to open the parsed file and check if Frama-C recognizes the ACSL annotations (they should show up in the CIL normalized code), or try other analyses, e.g. running frama-c -eva and checking that it detects the annotations.

Lexing error while running build ninja command

I am using ninja to build a program for the first time. I run the command ninja from the cmd but get the error:
ninja: error: build.ninja:3: lexing error
What is the issue?
Here is my build.ninja file:
rule compile
command = gcc -Wall -c $in -o $out
rule link
command = gcc $in -o $out
build hello.o: compile main.c
build hello: link hello.o `
and here is main.c:
int main() {
printf("Hello world\n");
return 0;
}

Applying patch to file in yocto recipe

I have a yocto recipe to compile a code from github. I modified some files and want to apply a patch to code fetched from github. Following is my recipe for building code.
SUMMARY = "Linux NFC stack for NCI based NXP NFC Controllers"
HOMEPAGE = "https://github.com/NXPNFCLinux/linux_libnfc-nci"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/include/linux_nfc_api.h;endline=17;md5=42fdb99b3ff2c12f594b22a774cb7308"
SECTION = "libs"
SRC_URI = "git://github.com/NXPNFCLinux/linux_libnfc-nci.git \
file:///home/pratyush/Desktop/custom_board/drivers/PN7150/linux_libnfc-nci/demoapp-main-patch1.patch"
SRCREV = "7cf539d3d9c0d682c8da5968fbf5615ae9993060"
PV = "2.1+git${SRCPV}"
EXTRA_OECONF =" --enable-pn7150"
S = "${WORKDIR}/git"
inherit autotools
FILES_${PN} += "${libdir}/libnfc_nci_linux-1.so"
FILES_SOLIBSDEV = "${libdir}/libnfc_nci_linux.so"
Following my patch to applied
--- /home/root/PN7150/linux_libnfc-nci/Makefile.am
+++ Makefile.am
## -1,7 +1,7 ##
lib_LTLIBRARIES = libnfc_nci_linux.la
-sbin_PROGRAMS = nfcDemoApp
-nfcDemoApp_DEPENDENCIES = libnfc_nci_linux.la
+sbin_PROGRAMS = readNfc
+readNfc_DEPENDENCIES = libnfc_nci_linux.la
LDFLAGS = -Bstatic
## -9,13 +9,13 ##
LDFLAGS += -L$(openssldir)/lib -lcrypto -lssl
endif
-nfcDemoApp_FLAGS = -I$(srcdir)/demoapp -I$(srcdir)/src/include
+readNfc_FLAGS = -I$(srcdir)/demoapp -I$(srcdir)/src/include
AM_CPPFLAGS = \
-I$(srcdir)/src/include \
$(INCLUDE_PARAMS) \
$(libnfc_nci_linux_la_FLAGS) \
- $(nfcDemoApp_FLAGS)
+ $(readNfc_FLAGS)
if LLCP1_3
AM_CPPFLAGS += \
## -177,7 +177,7 ##
src/service/linux_nfc_api.c \
src/service/linux_nfc_factory_api.c
-nfcDemoApp_SOURCES := \
+readNfc_SOURCES := \
demoapp/main.c \
demoapp/tools.c
## -231,6 +231,6 ##
libnfc_nci_linux_la_LDFLAGS +=-DPN551C2=3
libnfc_nci_linux_la_LDFLAGS += -shared -pthread -ldl -lrt -fPIC -release 1 -versionnfo 0:0:0
-nfcDemoApp_LDFLAGS = -pthread -ldl -lrt -lnfc_nci_linux
+readNfc_LDFLAGS = -pthread -ldl -lrt -lnfc_nci_linux
Thus I want to apply a patch from local to github fetched code. But whenever I try to bitbake apply patch I always get the following error:
can't find file to patch at input line 3
The problem is how you created your patch. The easiest way (if you're used to git) is to use git. Otherwise, diffing two complete source trees is a good and easy way.
One way to solve your issue would be to add ;striplevel=0 to the SRC_URI line. (A strip level of 1 is assumed by bitbake / OE).
Another way would be to modify your patch to start with:
--- a/Makefile.am
+++ b/Makefile.am
That should solve your problem.

Rcpp Compilation ERROR: 'clang: error: no such file or directory: '/usr/local/lib/libfontconfig.a'

I was trying to run this peace of code in R (credit to the author):
require(Rcpp)
require(RcppArmadillo)
require(inline)
cosineRcpp <- cxxfunction(
signature(Xs = "matrix"),
plugin = c("RcppArmadillo"),
body='
Rcpp::NumericMatrix Xr(Xs); // creates Rcpp matrix from SEXP
int n = Xr.nrow(), k = Xr.ncol();
arma::mat X(Xr.begin(), n, k, false); // reuses memory and avoids extra copy
arma::mat Y = arma::trans(X) * X; // matrix product
arma::mat res = (1 - Y / (arma::sqrt(arma::diagvec(Y)) * arma::trans(arma::sqrt(arma::diagvec(Y)))));
return Rcpp::wrap(res);
')
And got, after few fixes, the following error:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created!
clang: error: no such file or directory: '/usr/local/lib/libfontconfig.a'
clang: error: no such file or directory: '/usr/local/lib/libreadline.a'
make: *** [file5a681e35ebe1.so] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file5a681e35ebe1.cpp 2> file5a681e35ebe1.cpp.err.txt' had status 1
I used to use Rcpp a lot in the past. But between now and then my computer has been reformatted and all the installation re-done using homebrew.
I installed cairo with brew: brew install cairo
the libreadline.a error was solved with:
brew link --force readline
But the same did not work for libfontconfig.a since was already linked:
brew link --force fontconfig
Warning: Already linked: /usr/local/Cellar/fontconfig/2.11.1
To relink: brew unlink fontconfig && brew link fontconfig
I would have assumed that fontconfig is within cairo. In fact, when I type
brew install fontconfig
Warning: fontconfig-2.11.1 already installed
But the truth is that there is no libfontconfig.a at /usr/local/lib/:
ls /usr/local/lib/libfont*
/usr/local/lib/libfontconfig.1.dylib
/usr/local/lib/libfontconfig.dylib
Using the very questionable approach of going here and download it, the code runs, but still gives a the corresponding warning, since the file corresponds to a different os.x architecture (I did not found one for 10.9):
+ . + ld: warning: ignoring file /usr/local/lib/libfontconfig.a, missing required architecture x86_64 in file /usr/local/lib/libfontconfig.a (2 slices)
So at this stage I am a little lost.
How do I install libfontconfig.a or find the 10.9 version?
In case is of any use, I have Xcode installed, I am on a Mac 10.9.5,
and based on this very nice and detailed answer my ~/.R/Makevars file looks like:
CC=clang
CXX=clang++
FLIBS=-L/usr/local/bin/
Your system setup is broken. Neither R nor Rcpp have anything to do with clang (unless you chose clang as your system compiler) or fontconfig.
So start simpler:
R> library(Rcpp)
R> evalCpp("2 + 2")
[1] 4
R>
This just showed that my system has a working compiler R (and Rcpp) can talk to. We can it more explicit:
R> evalCpp("2 + 2", verbose=TRUE)
Generated code for function definition:
--------------------------------------------------------
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
SEXP get_value(){ return wrap( 2 + 2 ) ; }
No rebuild required (use rebuild = TRUE to force a rebuild)
[1] 4
R>
and R is clever enough not to rebuild. We can then force a build
R> evalCpp("2 + 2", verbose=TRUE, rebuild=TRUE)
Generated code for function definition:
--------------------------------------------------------
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
SEXP get_value(){ return wrap( 2 + 2 ) ; }
Generated extern "C" functions
--------------------------------------------------------
#include <Rcpp.h>
// get_value
SEXP get_value();
RcppExport SEXP sourceCpp_0_get_value() {
BEGIN_RCPP
Rcpp::RObject __result;
Rcpp::RNGScope __rngScope;
__result = Rcpp::wrap(get_value());
return __result;
END_RCPP
}
Generated R functions
-------------------------------------------------------
`.sourceCpp_0_DLLInfo` <- dyn.load('/tmp/Rtmpeuaiu4/sourcecpp_6a7c7c8295fc/sourceCpp_2.so')
get_value <- Rcpp:::sourceCppFunction(function() {}, FALSE, `.sourceCpp_0_DLLInfo`, 'sourceCpp_0_get_value')
rm(`.sourceCpp_0_DLLInfo`)
Building shared library
--------------------------------------------------------
DIR: /tmp/Rtmpeuaiu4/sourcecpp_6a7c7c8295fc
/usr/lib/R/bin/R CMD SHLIB -o 'sourceCpp_2.so' --preclean 'file6a7c6d1fc2d6.cpp'
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/tmp/Rtmpeuaiu4" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -c file6a7c6d1fc2d6.cpp -o file6a7c6d1fc2d6.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o sourceCpp_2.so file6a7c6d1fc2d6.o -L/usr/lib/R/lib -lR
[1] 4
R>
and on that you see system details on my side (Linux, also using ccache) that will be different for you.
After that, try (Rcpp)Armadillo one-liners and so on.

Oracle database installation issue in ins_ctx.mk

Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ins_ctx.mk'. See '/u01/app/oraInventory/logs/installActions2015-02-28_02-22-27AM.log' for details.
I get the above error when I run the installer of Oracle 11g release 2
The log is as follows
INFO: gcc -o ctxhx -m64 -L/u01/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ -L/u01/app/oracle/product/11.2.0/dbhome_1/lib/ -L/u01/app/oracle/product/11.2.0/dbhome_1/lib/stubs/ /u01/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ctxhx.o -L/u01/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ -lm -ldl -lsc_ca -lsc_fa -lsc_ex -lsc_da -lsc_ut -lsc_ch -lsc_fi -lctxhx -lc -Wl,-rpath,/u01/app/oracle/product/11.2.0/dbhome_1/ctx/lib -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -ls
INFO: nls11 -lnls11 -lcore11 -lnls11
INFO: /usr/bin/ld: /u01/app/oracle/product/11.2.0/dbhome_1/lib//libcore11.a(sslss.o): undefined reference to symbol 'pthread_sigmask##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
INFO: collect2: error: ld returned 1 exit status
INFO: make: *** [ctxhx] Error 1
INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'install' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ins_ctx.mk'. See '/u01/app/oraInventory/logs/installActions2015-02-28_02-22-27AM.log' for details.
Please help me fix this... Thanks in advance.
Try to link with g++ instead of gcc.
cd /bin
mv gcc gcc.save
ln -s g++ gcc
and run the installer again.
Create the following script the run it a root during install the click retry
# Fix ctx/lib/ins_ctx.mk
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
cat << __EOF__ > /tmp/memcpy_wrap.c
#include <stddef.h>
#include <string.h>
asm (".symver wrap_memcpy, memcpy#GLIBC_2.14");
void *wrap_memcpy(void *dest, const void *src, size_t n) {
return memcpy(dest, src, n);
}
__EOF__
if [[ -e "${ORACLE_HOME}/ctx/lib/ins_ctx.mk" ]]; then
sed -i -e 's/\$(INSO_LINK)/\$(INSO_LINK) -Wl,--wrap=memcpy_wrap \$(ORACLE_HOME)\/ctx\/lib\/memcpy_wrap.o/g' ${ORACLE_HOME}/ctx/lib/ins_ctx.mk
gcc -c /tmp/memcpy_wrap.c -o ${ORACLE_HOME}/ctx/lib/memcpy_wrap.o && rm /tmp/memcpy_wrap.c
fi

Resources