Re: [R] Rprintf will not build in my C++ compiler

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed, 30 Jul 2008 17:11:07 +0100 (BST)

That is a linker (not compiler) message, and you apparently forgot to link against R.dll. See README.packages in the R distribution for how to use VC++ with R under Windows (which is neither recommended nor supported).

Three other comments.

  1. See the posting guide. R-devel is the list for non-R programming questions.
  2. See the posting guide. You didn't show how you compiled your code nor what exact command gave that error message.
  3. See 'Writing R Extensions'. For that code to be any use with R, it has to have a C and not C++ entry point 'hello'.

On Wed, 30 Jul 2008, nmarti wrote:

>
> I have searched through the threads and "Rprintf" causing a build error
> dosen't seem to be a problem for anyone else. And I've read through "R
> Extensions" and "An Introduction to the .C Interface to R" and there doesn't
> seem to be any troubleshooting for my problem.

Well, you _are_ using an unsupported compiler/linker.

> My code is straight from "An Introduction to the .C Interface to R" pg. 3.

Which is what? (Not an official manual.)

> And my compiler is VC++ 2005 Express
> ----------------------
> #include <R.h>
>
> void hello( int *n ) {
> int i ;
> for( i = 0 ; i < *n ; i++ ) {
> Rprintf( "Hello, world!\n" ) ;
> }
> }
> ----------------------
> When I try to build this code, I recieve 2 error massages,
> "error LNK2019: unresolved external symbol _Rprintf referenced in function
> "void _cdecl hello(int *n)" (?hello@@YAXPAH_at_Z)"
> "fatal error LNK1120: 1 unresolved externals"
>
> To be honest, I'm not exactly sure what these errors mean, I'm still
> learning C++.
> Any thoughts would be appreciated.
> --
> View this message in context: http://www.nabble.com/Rprintf-will-not-build-in-my-C%2B%2B-compiler-tp18735205p18735205.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 30 Jul 2008 - 16:13:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 Jul 2008 - 22:33:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive