Skip to content

[Rcpp-devel] Defining template specialisation for wrap on Windows 64bit (Compilation error: 'result_type' does not name a type)

10 messages · Romain Francois, Dirk Eddelbuettel, Renaud Gaujoux

#
Hi,

I wanted to "quickly" port my package RcppOctave to run on Windows but
it turned out trickier than expected :(

I am getting compilation errors (8750 lines of errors - see first line below).
The code defines a specialisation for wrap, following the
non-intrusive way described in the vignette. Everything has always
worked smoothly on Linux (Ubuntu 13.10). On Windows there seems to be
some kind of conflict which messes up with type definitions, and this
happens as soon as I include Rcpp.h.
I noticed the "redefined" warnings before the error, but I am not sure
how this can break compilation that much.

Does anybody have a hint on this puzzling issue?
Thank you.

Bests,
Renaud

Minimal C++ code that produces the error:

//rcpp_octave.h

#ifndef _RcppOctave_RCPP_OCTAVE_H
#define _RcppOctave_RCPP_OCTAVE_H

#include <RcppCommon.h>

// Octave libraries
#include <octave/oct.h>

// declaring the specialization
namespace Rcpp {
    template <> SEXP wrap( const octave_value& );
}

// this must appear after the specialization,
// otherwise the specialization will not be seen by Rcpp types
#include <Rcpp.h>
#endif

####

//rcpp_octave.cpp

#include "rcpp_octave.h"

void dummy(){

}


### COMPILATION LOG ###

   [1] "* installing *source* package 'RcppOctave' ..."
   [2] "cygwin warning:"
   [3] "  MS-DOS style path detected: C:/R/R-30~1.2/bin/x64/R"
   [4] "  Preferred POSIX equivalent is:
/cygdrive/c/R/R-30~1.2/bin/x64/R"
   [5] "  CYGWIN environment variable option \"nodosfilewarning\"
turns off this warning."
   [6] "  Consult the user's guide for more details about POSIX
paths:"
   [7] "    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames"
   [8] "-lR: not found"
   [9] "Checking whether R is a shared library... YES"
  [10] "Using R LDFLAGS: -LC:/R/R-30~1.2/bin/x64 -lR"
  [11] "Using R CPPFLAGS: -IC:/R/R-30~1.2/include
-IC:/R/R-30~1.2/include/x64"
  [12] "Checking Octave include directory... "
  [13] "    C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave"
  [14] "    C:\\Octave\\Octave3.6.4_gcc4.6.2\\include"
  [15] "Checking Octave library directory...
C:\\Octave\\Octave3.6.4_gcc4.6.2\\lib\\octave\\3.6.4"
  [16] "Checking Octave version... 3.6.4"
  [17] "Checking whether to infer output names for Octave function (>=
3.4.3)... YES"
  [18] "RcppOctave Octave module directory...
z:/projects/RcppOctave/libwin/RcppOctave/modules"
  [19] "** libs"
  [20] "Warning: this package has a non-empty 'configure.win' file,"
  [21] "so building only the main architecture"
  [22] ""
  [23] "cygwin warning:"
  [24] "  MS-DOS style path detected: C:/R/R-30~1.2/etc/x64/Makeconf"
  [25] "  Preferred POSIX equivalent is:
/cygdrive/c/R/R-30~1.2/etc/x64/Makeconf"
  [26] "  CYGWIN environment variable option \"nodosfilewarning\"
turns off this warning."
  [27] "  Consult the user's guide for more details about POSIX
paths:"
  [28] "    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames"
  [29] "g++ -m64 -I\"C:/R/R-30~1.2/include\" -DNDEBUG
-IC:/R/R-3.0.2/library/Rcpp/include -DOCT_POST_3_4_0=1
-I\"C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\"
-I\"C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave\"
-I\"C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave/../\"
  -I\"C:/R/R-3.0.2/library/Rcpp/include\"
-I\"d:/RCompile/CRANpkg/extralibs64/local/include\"     -O2 -Wall
-mtune=core2 -c rcpp_octave.cpp -o rcpp_octave.o"
  [30] "In file included from
C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave/../octave/oct.h:31:0,"
  [31] "                 from rcpp_octave.h:10,"
  [32] "                 from rcpp_octave.cpp:21:"
  [33] "C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave/../octave/config.h:2764:0:
warning: \"_WIN32_WINNT\" redefined [enabled by default]"
  [34] "c:\\rtools\\gcc-4.6.3\\bin\\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/_mingw.h:244:0:
note: this is the location of the previous definition"
  [35] "In file included from
C:/R/R-3.0.2/library/Rcpp/include/Rcpp.h:50:0,"
  [36] "                 from rcpp_octave.h:25,"
  [37] "                 from rcpp_octave.cpp:21:"
  [38] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:156:21:
error: 'result_type' does not name a type"
  [39] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:161:24:
error: ISO C++ forbids declaration of 'operator()' with no type
[-fpermissive]"
  [40] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member
function 'int Rcpp::fixed_call< <template-parameter-1-1>
[41] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:162:41:
error: no matching function for call to 'as(SEXPREC*&)'"
  [42] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:162:41:
note: candidate is:"
  [43] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note:
template<class T> T Rcpp::as(SEXP)"
  [44] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: At global
scope:"
  [45] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:170:56:
error: template argument 2 is invalid"
  [46] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:176:41:
error: ISO C++ forbids declaration of 'operator()' with no type
[-fpermissive]"
  [47] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member
function 'int Rcpp::unary_call<T, <template-parameter-1-2>
[48] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:178:41:
error: no matching function for call to 'as(SEXPREC*&)'"
  [49] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:178:41:
note: candidate is:"
  [50] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note:
template<class T> T Rcpp::as(SEXP)"
  [51] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: At global
scope:"
  [52] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:187:62:
error: template argument 3 is invalid"
  [53] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:193:52:
error: ISO C++ forbids declaration of 'operator()' with no type
[-fpermissive]"
  [54] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member
function 'int Rcpp::binary_call<T1, T2, <template-parameter-1-3>
[55] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:196:41:
error: no matching function for call to 'as(SEXPREC*&)'"
  [56] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:196:41:
note: candidate is:"
  [57] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note:
template<class T> T Rcpp::as(SEXP)"
  [58] "In file included from
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Module.h:85:0,"
  [59] "                 from
C:/R/R-3.0.2/library/Rcpp/include/Rcpp.h:63,"
  [60] "                 from rcpp_octave.h:25,"
  [61] "                 from rcpp_octave.cpp:21:"
#
On 1 October 2013 at 17:20, Renaud Gaujoux wrote:
| I wanted to "quickly" port my package RcppOctave to run on Windows

Yay! Three cheers!

| but it turned out trickier than expected :(

Boo indeed.
 
| I am getting compilation errors (8750 lines of errors - see first line below).
| The code defines a specialisation for wrap, following the
| non-intrusive way described in the vignette. Everything has always
| worked smoothly on Linux (Ubuntu 13.10). On Windows there seems to be
| some kind of conflict which messes up with type definitions, and this
| happens as soon as I include Rcpp.h.

Ex-ante, that shouldn't happen, and rarely happens with Rcpp* code. There
generally is little platform specific code at the 'Rcpp user' package level.

So maybe, just maybe this comes from the Octave headers?  Could you possibly
separate this out and test the wrapping aspect on a mocked-up simple C++ class?

| I noticed the "redefined" warnings before the error, but I am not sure
| how this can break compilation that much.

There is a lot of line noise. Setting the 'nodosfilewarning' env var helps
with that. 
 
| Does anybody have a hint on this puzzling issue?

I'd simplify first. Try smaller example on Windows not involving Octave
headers. 

Dirk

| Thank you.
| 
| Bests,
| Renaud
| 
| Minimal C++ code that produces the error:
| 
| //rcpp_octave.h
| 
| #ifndef _RcppOctave_RCPP_OCTAVE_H
| #define _RcppOctave_RCPP_OCTAVE_H
| 
| #include <RcppCommon.h>
| 
| // Octave libraries
| #include <octave/oct.h>
| 
| // declaring the specialization
| namespace Rcpp {
|     template <> SEXP wrap( const octave_value& );
| }
| 
| // this must appear after the specialization,
| // otherwise the specialization will not be seen by Rcpp types
| #include <Rcpp.h>
| #endif
| 
| ####
| 
| //rcpp_octave.cpp
| 
| #include "rcpp_octave.h"
| 
| void dummy(){
| 
| }
| 
| 
| ### COMPILATION LOG ###
| 
|    [1] "* installing *source* package 'RcppOctave' ..."
|    [2] "cygwin warning:"
|    [3] "  MS-DOS style path detected: C:/R/R-30~1.2/bin/x64/R"
|    [4] "  Preferred POSIX equivalent is:
| /cygdrive/c/R/R-30~1.2/bin/x64/R"
|    [5] "  CYGWIN environment variable option \"nodosfilewarning\"
| turns off this warning."
|    [6] "  Consult the user's guide for more details about POSIX
| paths:"
|    [7] "    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames"
|    [8] "-lR: not found"
|    [9] "Checking whether R is a shared library... YES"
|   [10] "Using R LDFLAGS: -LC:/R/R-30~1.2/bin/x64 -lR"
|   [11] "Using R CPPFLAGS: -IC:/R/R-30~1.2/include
| -IC:/R/R-30~1.2/include/x64"
|   [12] "Checking Octave include directory... "
|   [13] "    C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave"
|   [14] "    C:\\Octave\\Octave3.6.4_gcc4.6.2\\include"
|   [15] "Checking Octave library directory...
| C:\\Octave\\Octave3.6.4_gcc4.6.2\\lib\\octave\\3.6.4"
|   [16] "Checking Octave version... 3.6.4"
|   [17] "Checking whether to infer output names for Octave function (>=
| 3.4.3)... YES"
|   [18] "RcppOctave Octave module directory...
| z:/projects/RcppOctave/libwin/RcppOctave/modules"
|   [19] "** libs"
|   [20] "Warning: this package has a non-empty 'configure.win' file,"
|   [21] "so building only the main architecture"
|   [22] ""
|   [23] "cygwin warning:"
|   [24] "  MS-DOS style path detected: C:/R/R-30~1.2/etc/x64/Makeconf"
|   [25] "  Preferred POSIX equivalent is:
| /cygdrive/c/R/R-30~1.2/etc/x64/Makeconf"
|   [26] "  CYGWIN environment variable option \"nodosfilewarning\"
| turns off this warning."
|   [27] "  Consult the user's guide for more details about POSIX
| paths:"
|   [28] "    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames"
|   [29] "g++ -m64 -I\"C:/R/R-30~1.2/include\" -DNDEBUG
| -IC:/R/R-3.0.2/library/Rcpp/include -DOCT_POST_3_4_0=1
| -I\"C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\"
| -I\"C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave\"
| -I\"C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave/../\"
|   -I\"C:/R/R-3.0.2/library/Rcpp/include\"
| -I\"d:/RCompile/CRANpkg/extralibs64/local/include\"     -O2 -Wall
| -mtune=core2 -c rcpp_octave.cpp -o rcpp_octave.o"
|   [30] "In file included from
| C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave/../octave/oct.h:31:0,"
|   [31] "                 from rcpp_octave.h:10,"
|   [32] "                 from rcpp_octave.cpp:21:"
|   [33] "C:\\Octave\\Octave3.6.4_gcc4.6.2\\include\\octave-3.6.4\\octave/../octave/config.h:2764:0:
| warning: \"_WIN32_WINNT\" redefined [enabled by default]"
|   [34] "c:\\rtools\\gcc-4.6.3\\bin\\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/_mingw.h:244:0:
| note: this is the location of the previous definition"
|   [35] "In file included from
| C:/R/R-3.0.2/library/Rcpp/include/Rcpp.h:50:0,"
|   [36] "                 from rcpp_octave.h:25,"
|   [37] "                 from rcpp_octave.cpp:21:"
|   [38] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:156:21:
| error: 'result_type' does not name a type"
|   [39] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:161:24:
| error: ISO C++ forbids declaration of 'operator()' with no type
| [-fpermissive]"
|   [40] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member
| function 'int Rcpp::fixed_call< <template-parameter-1-1>
| >::operator()()':"
|   [41] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:162:41:
| error: no matching function for call to 'as(SEXPREC*&)'"
|   [42] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:162:41:
| note: candidate is:"
|   [43] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note:
| template<class T> T Rcpp::as(SEXP)"
|   [44] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: At global
| scope:"
|   [45] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:170:56:
| error: template argument 2 is invalid"
|   [46] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:176:41:
| error: ISO C++ forbids declaration of 'operator()' with no type
| [-fpermissive]"
|   [47] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member
| function 'int Rcpp::unary_call<T, <template-parameter-1-2>
| >::operator()(const T&)':"
|   [48] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:178:41:
| error: no matching function for call to 'as(SEXPREC*&)'"
|   [49] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:178:41:
| note: candidate is:"
|   [50] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note:
| template<class T> T Rcpp::as(SEXP)"
|   [51] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: At global
| scope:"
|   [52] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:187:62:
| error: template argument 3 is invalid"
|   [53] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:193:52:
| error: ISO C++ forbids declaration of 'operator()' with no type
| [-fpermissive]"
|   [54] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member
| function 'int Rcpp::binary_call<T1, T2, <template-parameter-1-3>
| >::operator()(const T1&, const T2&)':"
|   [55] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:196:41:
| error: no matching function for call to 'as(SEXPREC*&)'"
|   [56] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:196:41:
| note: candidate is:"
|   [57] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note:
| template<class T> T Rcpp::as(SEXP)"
|   [58] "In file included from
| C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Module.h:85:0,"
|   [59] "                 from
| C:/R/R-3.0.2/library/Rcpp/include/Rcpp.h:63,"
|   [60] "                 from rcpp_octave.h:25,"
|   [61] "                 from rcpp_octave.cpp:21:"
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
#
Renaud,

Are you by any chance using cywin ?
This is not likely to fly.

To check if this is an octave problem, what happens when you do:

 > evalCpp( "2+2" )

Romain

Le 01/10/13 17:20, Renaud Gaujoux a ?crit :

  
    
#
Indeed wouldn't it be nice to get it working on windows uh? I had a
number of queries for this recently...
Yes, sorry I did not mentioned this. This is definitely linked with
Octave. I did try defining a wrap specialisation without Octave and it
worked fine, so no issues on your side :)

So the question would rather be: has anybody experienced such error
when defining specialisation to third-party classes, for which one
does not control includes, defines, etc...?
1 day later
#
Some follow up on this issue.
RcppOctave ships an Octave module that call R own RNG functions, and
hence need to be compiled against R libraries. The compilation works
fine on both Linux and Windows (see details below). Note that using
R_NO_REMAP here really does not make a difference, but I still use it
just in case. So R and Octave headers are happy together.

The error really happens at the line where Rccp.h is included, not
when including RcppCommon.h, nor when declaring the wrap
specialisation. This is maybe something specific to templates? Are
these known to be handled differently in Windows and Linux (in
general, not specifically Rcpp)?

Renaud


##############
The includes for this module are declared as follows:

// Octave includes
#include <octave/config.h>
#include <octave/oct-obj.h>
#include <octave/oct-map.h>
#include <octave/defun-dld.h>

// STD includes
#include <limits.h>

#define R_NO_REMAP
#include <Rmath.h>
#include <R_ext/Random.h>

The compilation and linking are performed via mkoctfile, only adding
includes and lib directives to R stuff, as follows:

$ mkoctfile -v -IC:/R/R-3.0.2/include -IC:/R/R-3.0.2/include/i386
-LC:/R/R-3.0.2/bin/i386 -lR -lR  Rrng.cc

g++ -shared-libgcc -c -I/c/OctaveB/gplibs/include
-I/c/OctaveB/OctaveLibs/include -I/c/OctaveB/GnuWin32/include
-IC:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave\..
-IC:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave
-IC:\Octave\Octave3.6.4_gcc4.6.2\include -mieee-fp
-IC:/OctaveB/gplibs/include/freetype2 -IC:/OctaveB/gplibs/include
-IC:/OctaveB/gplibs/include   -g -O2   -IC:/R/R-3.0.2/include
-IC:/R/R-3.0.2/include/i386  Rrng.cc -o Rrng.o

g++ -shared-libgcc -shared -Wl,--export-all-symbols
-Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc  -o
Rrng.oct  Rrng.o   -LC:/R/R-3.0.2/bin/i386 -lR -lR
-LC:\Octave\Octave3.6.4_gcc4.6.2\lib\octave\3.6.4
-LC:\Octave\Octave3.6.4_gcc4.6.2\lib -loctinterp -loctave -lcruft
On 1 October 2013 17:51, Renaud Gaujoux <renaud at mancala.cbio.uct.ac.za> wrote:
#
On 3 October 2013 at 12:51, Renaud Gaujoux wrote:
| Some follow up on this issue.
| RcppOctave ships an Octave module that call R own RNG functions, and
| hence need to be compiled against R libraries. The compilation works
| fine on both Linux and Windows (see details below). Note that using
| R_NO_REMAP here really does not make a difference, but I still use it
| just in case. So R and Octave headers are happy together.
| 
| The error really happens at the line where Rccp.h is included, not
| when including RcppCommon.h, nor when declaring the wrap
| specialisation. This is maybe something specific to templates? Are
| these known to be handled differently in Windows and Linux (in
| general, not specifically Rcpp)?

Sorry, I do not know. 

If you only need the RNGs from R, did you consider using R's standalone Math
library?  We can build that fine on Linux, maybe it can be built on Windows?
(Not sure anybody would have it ...)

A complete example including the compile / link is (first comment line wrapped)

    // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; \
           compile-command: "gcc -s -Wall -O3 -I/usr/share/R/include \
                             -o rmath_qbeta rmath_qbeta.c -lRmath -lm" -*-

    #include <stdio.h>
    
    #define MATHLIB_STANDALONE 1
    #include <Rmath.h>
    
    int main(void) {
    
        double x = 0.25, a = 0.8, b = 2.0;
    
        printf("qbeta: %f %f %f %f\n", 
                qbeta(x, a, b, 0, 0), 
                qbeta(log(x), a, b, 0, 1), 
                qbeta(x,     a, b, 1, 0), 
                qbeta(log(x), a, b, 1, 1));
        
        return 0;
    }


Dirk
#
Thanks Dirk for shooting ideas here :)
In short: 1) not needed 2) not wanted

In long:
1) not needed: the RNGs are used in the Octave modules, which build
fine on both Linux and Windows against the current (not standalone) R
library.
2) not wanted: I link against the currently used R library because I
want to use exactly its RNG, with synchronised seed etc... libRmath
only provides one kind of RNG, which is not even the default RNG in
vanilla R (who knows why...) No ways of forcing a particular seed
(i.e. an RNG kind).

I wish I could solve this issue, which is probably linked to some
strange conflict, since I don't think I use any Linux specific stuff,
only std. Seemed just a few steps to the cross-platform leap :(

Renaud
#
On 3 October 2013 at 14:45, Renaud Gaujoux wrote:
| Thanks Dirk for shooting ideas here :)
| 
| >
| > If you only need the RNGs from R, did you consider using R's standalone Math
| > library?  We can build that fine on Linux, maybe it can be built on Windows?
| > (Not sure anybody would have it ...)
| >
| 
| In short: 1) not needed 2) not wanted
| 
| In long:
| 1) not needed: the RNGs are used in the Octave modules, which build
| fine on both Linux and Windows against the current (not standalone) R
| library.

I understand that. But I fear you are bitten by a side-effect of linking
against the full R on Windows, and linking against a much smaller subset may
give you a better chance at success (conditional on my first hypothesis being
correct, which may be unlikely ;-)

| 2) not wanted: I link against the currently used R library because I
| want to use exactly its RNG, with synchronised seed etc... libRmath
| only provides one kind of RNG, which is not even the default RNG in
| vanilla R (who knows why...) No ways of forcing a particular seed
| (i.e. an RNG kind).

I always confuse myself here but I thought you could get all distributions
and all generators -- see help("RNGkind").

Yes -- Here is a 1-minute mod to the earlier qbeta() example using rnorm()
from R:

edd at max:~/src/progs/C$ cat rmath_rnorm.c
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; compile-command: "gcc -s -Wall -O3 -I/usr/share/R/include -o rmath_rnorm rmath_rnorm.c -lRmath -lm" -*-

#include <stdio.h>

#define MATHLIB_STANDALONE 1
#include <Rmath.h>

int main(void) {

    set_seed(123, 456);
    printf("rnorm: %f %f\n", rnorm(0.0, 1.0), rnorm(0.0, 1.0));
    
    return 0;
}
edd at max:~/src/progs/C$ ./rmath_rnorm 
rnorm: -0.334377 -0.293497
edd at max:~/src/progs/C$ ./rmath_rnorm 
rnorm: -0.334377 -0.293497
edd at max:~/src/progs/C$ 


The only thing left is figuring out how to go from R's single-arg set.seed()
to this one.  I think I once looked into this when I connected R's RNGs to
(R)Dieharder a few years back but I can't quite recall what the story was.
 
| I wish I could solve this issue, which is probably linked to some
| strange conflict, since I don't think I use any Linux specific stuff,
| only std. Seemed just a few steps to the cross-platform leap :(

Yes, this needs a Windows expert.

Dirk
#
The error occurs on compilation not linking. It occurs when compiling
the RcppOctave library, which is made against full R since it is the
package's library and will be called from an R session. Can this one
be linked against libRmath? Besides, can Rcpp code be linked against
libRmath?
Last time I looked at RNG.c (or filename like that) in R source code,
you could not get anything else than Marsaglia.
That's the thing, set.seed is the only exported function that can
touch the RNG and only enables to set the 2-length seed for Marsaglia,
and the kind cannot be changed, see (which also interestingly tells
you something about the order of evaluation of printf arguments...):

Rscript -e "RNGkind('Marsaglia'); .Random.seed[2:3] <- c(123L, 456L); rnorm(2)"
[1] -0.2934974 -0.3343770
Anybody around listening to us?


Renaud
#
On 3 October 2013 at 15:39, Renaud Gaujoux wrote:
| Last time I looked at RNG.c (or filename like that) in R source code,
| you could not get anything else than Marsaglia.

The Marsaglia generator to seed all distributions.  

So if you want the 20+ distributions rlnorm(), rweibull(), ... you are good.
If you to comparese different U(0,1) generators you are not. I though you
wanted the former--sorry if I misunderstood.

| That's the thing, set.seed is the only exported function that can
| touch the RNG and only enables to set the 2-length seed for Marsaglia,
| and the kind cannot be changed, see (which also interestingly tells
| you something about the order of evaluation of printf arguments...):
| 
| Rscript -e "RNGkind('Marsaglia'); .Random.seed[2:3] <- c(123L, 456L); rnorm(2)"
| [1] -0.2934974 -0.3343770

Nice. There is the (partial) equivalence (subject to ordering).

Dirk