Skip to content

Addendum to “A Hello World R package”: using C++ instead of C

In my previous post about writing an R extension, I the reason why I chose to use C instead of C++ was because I couldn’t find a way to tell R tools that they should use the C++ compiler, g++, and not the C compiler, gcc. Well, it turned out that the solution was trivial: you just need to change the extension: for C, the extension is .c; for C++, the extension can be .cc, .cpp or .C. I had actually already tried .cpp with no success, so probably did something else wrong at that time…

It is to be noted, however, that .Call doesn’t seem too happy about this modification, and for the moment I haven’t been able to fix that new error in the hello world package C++ version:

Error in .Call(“helloWorldC”, n = n, m = m, PACKAGE = “helloworld”) :
C symbol name “helloWorldC” not in DLL for package “helloworld”

Posted in programming, R (R-project).

2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. David says

    Did you ever find a solution to this problem? I’m in the same mess and can’t figure why.

  2. patheticcockroach says

    Nope, I got tired of this poor non-existent documentation and ended up implementing the C++ part as a stand-alone application. Worked just as fine for what I was doing (very few calls to that application in a run). I know, that’s cheating but I had some deadlines coming 😉
    I’d be much interested to know if you eventually find a fix!

Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA