Question

The software I am talking of contains 5 files and compiles "perfectly fine" on openSUSE 11.3 with gcc-4.5.1:

The same software shows the following error on Windows XP with Mingw (gcc-4.6.3).

UPDATE

The problem is discovered.

The problem is w.r.t the R's function parseEval. There are two similar functions: parseEval and parseEvalQ. The former returns a value, and the other returns void.

I have used parseEval in a C++ plus Qt project, and it works very fine on Linux, and throws the above shown error on Windows.

Here is the reproducible example:

demo.cpp

#include <iostream>
#include <RInside.h>
#include <Rcpp.h>

RInside R (0, NULL);
RInside & qtToR (R);

int main ()
{
    int numberOne = 1;
    int numberTwo = 2;

    qtToR ["numberOne"] = numberOne;
    qtToR ["numberTwo"] = numberTwo;

    R.parseEvalQ ("sum = numberOne + numberTwo;");

    int returnValue = R.parseEval ("sum");
    std :: cout << "\n" << returnValue << "\n";
}

Corresponding .pro file:

TEMPLATE    = app
TARGET      =
DEPENDPATH  += .

SOURCES     += demo.cpp

INCLUDEPATH += .
INCLUDEPATH += c:/R-2.15.1/include
INCLUDEPATH += c:/R-2.15.1/library/Rcpp/include
INCLUDEPATH += c:/R-2.15.1/library/RInside/include

LIBS        += -Lc:/R-2.15.1/bin/i386 -lR
LIBS        += -Lc:/R-2.15.1/library/Rcpp/libs/i386 -lRcpp
LIBS        += -Lc:/R-2.15.1/library/RInside/libs/i386 -lRInside

# You'll keep pulling your hair if you miss this statement when you are on windows.
CONFIG      += console

enter image description here

Was it helpful?

Solution 2

I said:

This is solved. The problem was NOT related to the .pro file, it was related to the syntax of parseEval function. The RInside I have on Linux is older than RInside I have on Windows. The versions of Rcpp installed are also different on my Linux system and Windows system.

This syntax of parseEval - int returnValue = R.parseEval ("sum"); works fine on Linux with older RInside but fails on Windows with newer RInside.

So, I modified the above code as follows and it compiled successfully with the above .pro file.

SEXP ans; int returnValue = R.parseEval ("sum", ans);

This did compile successfully, but to my horror this joy was just the calmness before the storm!
The same error had now shifted to the run time!

So, the permanent solution to this error is editing the .pro file and linking Rcpp AFTER RInside:

LIBS += -Lc:/R-2.15.1/library/RInside/libs/i386 -lRInside
LIBS += -Lc:/R-2.15.1/library/Rcpp/libs/i386 -lRcpp

OTHER TIPS

Linking semantics is different in Linux and in Windows, notably for dynamic libraries.

I suggest to read Levine's linkers and loaders book.

See also this question, and look for Gcc function attributes, dllexport and dllimport.

With Qt, you may need to use Q_DECL_EXPORT etc.... (This Qt macro will work both on Linux and on Windows).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top