SWIG R with c++11

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

SWIG R with c++11

Peter Caspers-4
Hi,

   is it possible to build the SWIG R package with -std=c++11 ? As far
as I can see during the execution of R CMD check R one step

* checking whether package ‘QuantLib’ can be installed ... ERROR

fails because some hard coded (?) configuration (not related to the one
produced with the usual ./configure ... call) is used here, in the log
R.Rcheck/00install.out I get

make[3]: Entering directory `/home/peter/quantlibpc/QuantLib-SWIG/R/src'
g++ -I/usr/share/R/include -DNDEBUG `quantlib-config --cflags`      -fpic  -O3 -pipe  -g  -c QuantLib.cpp -o QuantLib.o

which fails because of some c++11 elements in my client quantlib code.

Thanks a lot
    Peter




------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: SWIG R with c++11

Dirk Eddelbuettel

Hi Peter,

On 26 October 2013 at 21:34, Peter Caspers wrote:
|    is it possible to build the SWIG R package with -std=c++11 ? As far
| as I can see during the execution of R CMD check R one step
|
| * checking whether package ‘QuantLib’ can be installed ... ERROR
|
| fails because some hard coded (?) configuration (not related to the one
| produced with the usual ./configure ... call) is used here, in the log
| R.Rcheck/00install.out I get
|
| make[3]: Entering directory `/home/peter/quantlibpc/QuantLib-SWIG/R/src'
| g++ -I/usr/share/R/include -DNDEBUG `quantlib-config --cflags`      -fpic  -O3 -pipe  -g  -c QuantLib.cpp -o QuantLib.o
|
| which fails because of some c++11 elements in my client quantlib code.

Interesting question. The whole 'R and C++11' nexus is a little toxic (as the
CRAN gatekeepers exists on the older standard; some of us are working behind
the scenes to change that).  By and large, using -std=c++11 should not bite.
We use it for a things with Rcpp,  but because we cannot (yet!!) upload to
CRAN with it, there isn't as much testing for C++11.  

R itself is in C and does not care. Boost may care (and Boost 2.0 will be
guaranteed to work this way). No idea about Swig. I haven't built the QL-Swig
bindings in a while.

Now, your post doesn't actually show the error. What happens when you simply
set appropriate CXXFLAGS as in

    CXXFLAGS= -g -O3 -Wall -pipe -Wno-unused -pedantic -std=c++11

(I usually do that in ~/.R/Makevars; you can also set it per package in
src/Makevars).

Can you try and report back?

Dirk

--
Dirk Eddelbuettel | [hidden email] | http://dirk.eddelbuettel.com

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: SWIG R with c++11

Peter Caspers-4
Hi Dirk,

thank you. With

CXX=clang++
CXXFLAGS=-g -O3 -Wall -pipe -Wno-unused -pedantic -std=c++11

in ~/R/Makevars make runs smooth on my code. I get 12 warnings of type

QuantLib.cpp:552:7: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]

which does not look critical, and 3 warnings

* checking DESCRIPTION meta-information ... WARNING
Non-standard license specification:
  QuantLib License
Standardizable: FALSE

* checking for missing documentation entries ... WARNING
Undocumented code objects:
  ‘ARSCurrency’ ‘ATSCurrency’ ‘AUDCurrency’ ‘AUDLibor’
  ‘AUDLibor__SWIG_0’ ‘AUDLibor__SWIG_1’ ‘Actual360’ ‘Actual365Fixed’
  ‘Actual365NoLeap’ ‘ActualActual’ ‘ActualActual__SWIG_0’
...

* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.

again not dangerous, are they.

Also then running R CMD INSTALL . goes without problems. After that I
have a QuantLib.so which I can load from R

dyn.load('/usr/local/lib/R/site-library/QuantLib/libs/QuantLib.so')

and after

source('~/quantlibpc/QuantLib-SWIG/R/R/QuantLib.R')

I can succesfully run a few basic tests with QuantLib objects.

However there does not seem to be the compiled wrapper QuantLib.RData
generated. Was it renamed maybe or do I have to generate it by myself ?

Thanks a lot
    Peter

Dirk Eddelbuettel <[hidden email]> writes:

> Hi Peter,
>
> On 26 October 2013 at 21:34, Peter Caspers wrote:
> |    is it possible to build the SWIG R package with -std=c++11 ? As far
> | as I can see during the execution of R CMD check R one step
> |
> | * checking whether package ‘QuantLib’ can be installed ... ERROR
> |
> | fails because some hard coded (?) configuration (not related to the one
> | produced with the usual ./configure ... call) is used here, in the log
> | R.Rcheck/00install.out I get
> |
> | make[3]: Entering directory `/home/peter/quantlibpc/QuantLib-SWIG/R/src'
> | g++ -I/usr/share/R/include -DNDEBUG `quantlib-config --cflags`      -fpic  -O3 -pipe  -g  -c QuantLib.cpp -o QuantLib.o
> |
> | which fails because of some c++11 elements in my client quantlib code.
>
> Interesting question. The whole 'R and C++11' nexus is a little toxic (as the
> CRAN gatekeepers exists on the older standard; some of us are working behind
> the scenes to change that).  By and large, using -std=c++11 should not bite.
> We use it for a things with Rcpp,  but because we cannot (yet!!) upload to
> CRAN with it, there isn't as much testing for C++11.  
>
> R itself is in C and does not care. Boost may care (and Boost 2.0 will be
> guaranteed to work this way). No idea about Swig. I haven't built the QL-Swig
> bindings in a while.
>
> Now, your post doesn't actually show the error. What happens when you simply
> set appropriate CXXFLAGS as in
>
>     CXXFLAGS= -g -O3 -Wall -pipe -Wno-unused -pedantic -std=c++11
>
> (I usually do that in ~/.R/Makevars; you can also set it per package in
> src/Makevars).
>
> Can you try and report back?
>
> Dirk

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: SWIG R with c++11

Dirk Eddelbuettel

Hi Peter,

On 27 October 2013 at 10:45, Peter Caspers wrote:
| thank you. With
|
| CXX=clang++
| CXXFLAGS=-g -O3 -Wall -pipe -Wno-unused -pedantic -std=c++11
|
| in ~/R/Makevars make runs smooth on my code. I get 12 warnings of type
|
| QuantLib.cpp:552:7: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
|
| which does not look critical, and 3 warnings
|
| * checking DESCRIPTION meta-information ... WARNING
| Non-standard license specification:
|   QuantLib License
| Standardizable: FALSE

Normal.

R stocks a set of licenses (on Debian/Ubuntu in /usr/share/R/share/licenses/)
but does not know our one. Which does not matter as we'd never ever push this
as a package to CRAN (as we'd need R help page entry for each callable
function etc pp)
 
| * checking for missing documentation entries ... WARNING
| Undocumented code objects:
|   ‘ARSCurrency’ ‘ATSCurrency’ ‘AUDCurrency’ ‘AUDLibor’
|   ‘AUDLibor__SWIG_0’ ‘AUDLibor__SWIG_1’ ‘Actual360’ ‘Actual365Fixed’
|   ‘Actual365NoLeap’ ‘ActualActual’ ‘ActualActual__SWIG_0’
| ...

Yep. As expected.
 
| * checking PDF version of manual ... WARNING
| LaTeX errors when creating PDF version.
| This typically indicates Rd problems.
|
| again not dangerous, are they.
|
| Also then running R CMD INSTALL . goes without problems. After that I
| have a QuantLib.so which I can load from R
|
| dyn.load('/usr/local/lib/R/site-library/QuantLib/libs/QuantLib.so')
|
| and after
|
| source('~/quantlibpc/QuantLib-SWIG/R/R/QuantLib.R')

Nooooooooooooo!!!  That is wrong.  

The changes I made a few months ago allow you to

     a) create what looks like an R package to R

     b) install it like an R package

     c) use it like an R package.

In short:   R -e 'library(QuantLib); callWhatEverYouWantHere()'
and of course also in a longer interactive sesssion. Here QuantLib is the
package we got out of QL's SWIG work.

Doing it this is

     d) portable as R knows whether your library ends in .so, .dll or .dynlib

     e) well understood and a standard in the eosystem you entered: R

     f) hence _much_ easier on users

     g) also deals with all the metadata (eg the RData)

     h) makes R aware of the package too (eg library() sees it)

I apologize for having taken years to make the somewhat small changes to all
the excellent work Joe had to make it build under SWIG.  Once you have a
package, it all works much, much better.
 
| I can succesfully run a few basic tests with QuantLib objects.
|
| However there does not seem to be the compiled wrapper QuantLib.RData
| generated. Was it renamed maybe or do I have to generate it by myself ?

You do that too as part of the package build and load. Automagically.

Please lets keep this thread going. Between you, Klaus, Joe, myself, we
shoukld get some mojo back into QuantLib and R.  (And yes, I still plan to
renovate RQuantLib. Help welcome. Repo on R-Forge, would be happy to move to
GH if folks think it helped.)

Dirk

--
Dirk Eddelbuettel | [hidden email] | http://dirk.eddelbuettel.com

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: SWIG R with c++11

Peter Caspers-4
Hi Dirk,

> |
> | dyn.load('/usr/local/lib/R/site-library/QuantLib/libs/QuantLib.so')
> |
> | and after
> |
> | source('~/quantlibpc/QuantLib-SWIG/R/R/QuantLib.R')
>
> Nooooooooooooo!!!  That is wrong.  
>

don't panic, my fault. I tend to read through readmes too fast, then
often missing the lines on the top ... yes, your new way of doing it
works very well.

> Please lets keep this thread going. Between you, Klaus, Joe, myself, we
> shoukld get some mojo back into QuantLib and R.  (And yes, I still plan to
> renovate RQuantLib. Help welcome. Repo on R-Forge, would be happy to move to
> GH if folks think it helped.)

sure. Maybe GH would support collaboration better. Don't know R-Forge though.

Thanks for you help
    Peter


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev