[R] R CMD SHLIB changes function name when compiling

2010-10-08 Thread Steve Pederson

Hi,

I'm trying to write a function in C for implementation with .Call. When 
compiling using R CMD SHLIB characters seem to be added to the function 
name.


Here's the complete C code from the file summariseMCMC.c:

#includeR.h
#includeRdefines.h
#includeRinternals.h

void summariseMCMC(SEXP data) {

PROTECT(data=AS_NUMERIC(data));
UNPROTECT(1);

}

Then after compiling  (R CMD SHLIB summariseMCMC.c)  loading the .dll

dyn.load(C:/R/R-2.11.1/bin/summariseMCMC.dll)
is.loaded(_Z13summariseMCMCP7SEXPREC)
[1] TRUE
is.loaded(summariseMCMC)
[1] FALSE

Just wondering if anyone had any pointers for getting rid of this, or 
have I missed something outrageously obvious?


Thanks,

Steve


sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
 [1] limma_3.4.4Biobase_2.8.0  aroma.affymetrix_1.7.0
 [4] aroma.apd_0.1.7affxparser_1.20.0  R.huge_0.2.0
 [7] aroma.core_1.7.0   aroma.light_1.16.0 matrixStats_0.2.1
[10] R.rsp_0.3.6R.cache_0.3.0  R.filesets_0.8.3
[13] digest_0.4.2   R.utils_1.4.4  R.oo_1.7.3
[16] R.methodsS3_1.2.0

loaded via a namespace (and not attached):
[1] tools_2.11.1

__
R-help@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.


Re: [R] R CMD SHLIB changes function name when compiling

2010-10-08 Thread Prof Brian Ripley

On Fri, 8 Oct 2010, Steve Pederson wrote:


Hi,

I'm trying to write a function in C for implementation with .Call. When 
compiling using R CMD SHLIB characters seem to be added to the function name.


Here's the complete C code from the file summariseMCMC.c:

#includeR.h
#includeRdefines.h
#includeRinternals.h

void summariseMCMC(SEXP data) {

   PROTECT(data=AS_NUMERIC(data));
   UNPROTECT(1);

}

Then after compiling  (R CMD SHLIB summariseMCMC.c)  loading the .dll

dyn.load(C:/R/R-2.11.1/bin/summariseMCMC.dll)
is.loaded(_Z13summariseMCMCP7SEXPREC)
[1] TRUE
is.loaded(summariseMCMC)
[1] FALSE

Just wondering if anyone had any pointers for getting rid of this, or have I 
missed something outrageously obvious?


You have.  This was not done by'R CMD SHLIB', but by a C++ compiler -- 
it is called 'name mangling'. Unfortunately you didn't show us the 
output from that command, when the cause would probably have been 
'outrageously obvious'.


The fix is to make sure you use a C compiler to compile C code, and 
we've almost no idea why that is not being done on your system.

But as a guess, check that the environment variable CC is not set.



Thanks,

Steve


sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] limma_3.4.4Biobase_2.8.0  aroma.affymetrix_1.7.0
[4] aroma.apd_0.1.7affxparser_1.20.0  R.huge_0.2.0
[7] aroma.core_1.7.0   aroma.light_1.16.0 matrixStats_0.2.1
[10] R.rsp_0.3.6R.cache_0.3.0  R.filesets_0.8.3
[13] digest_0.4.2   R.utils_1.4.4  R.oo_1.7.3
[16] R.methodsS3_1.2.0

loaded via a namespace (and not attached):
[1] tools_2.11.1

__
R-help@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,  rip...@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, UKFax:  +44 1865 272595

__
R-help@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.


Re: [R] R CMD SHLIB changes function name when compiling

2010-10-08 Thread Steve Pederson

Hi Prof Ripley,

Thanks for the response  the use of the correct terminology. I've 
checked the environment variables  there is none set called CC.


The .dll was definitely compiled using R CMD SHLIB. I'm not quite sure 
what output you're referring to but at the command prompt when I enter:


...\bin R CMD SHLIB summariseMCMC.C

I get the output:

g++ -IC:/R/R-2.11.1/include-02 -Wall summariseMCMC.c 
summariseMCMC.o
g++ -shared -s -static-libgcc -o summariseMCMC.dll tmp.def 
summariseMCMC.0 -LC:/R/R-2.11.1/bin -1R


Please let me know if I can try anything different provide any more 
useful output.


Another source file I have (runUniformMCMC.C) compiles  runs perfectly 
using the same approach, so I'm rather perplexed as to why this one gets 
it's name mangled. It originally had actual code in it that did useful 
things, but I stripped it back while I was trying to figure out what is 
happening.


Thanks again,

Steve


On 8/10/2010 8:06 PM, Prof Brian Ripley wrote:

On Fri, 8 Oct 2010, Steve Pederson wrote:


Hi,

I'm trying to write a function in C for implementation with .Call.
When compiling using R CMD SHLIB characters seem to be added to the
function name.

Here's the complete C code from the file summariseMCMC.c:

#includeR.h
#includeRdefines.h
#includeRinternals.h

void summariseMCMC(SEXP data) {

PROTECT(data=AS_NUMERIC(data));
UNPROTECT(1);

}

Then after compiling (R CMD SHLIB summariseMCMC.c)  loading the .dll

dyn.load(C:/R/R-2.11.1/bin/summariseMCMC.dll)
is.loaded(_Z13summariseMCMCP7SEXPREC)
[1] TRUE
is.loaded(summariseMCMC)
[1] FALSE

Just wondering if anyone had any pointers for getting rid of this, or
have I missed something outrageously obvious?


You have. This was not done by'R CMD SHLIB', but by a C++ compiler -- it
is called 'name mangling'. Unfortunately you didn't show us the output
from that command, when the cause would probably have been 'outrageously
obvious'.

The fix is to make sure you use a C compiler to compile C code, and
we've almost no idea why that is not being done on your system.
But as a guess, check that the environment variable CC is not set.



Thanks,

Steve


sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] limma_3.4.4 Biobase_2.8.0 aroma.affymetrix_1.7.0
[4] aroma.apd_0.1.7 affxparser_1.20.0 R.huge_0.2.0
[7] aroma.core_1.7.0 aroma.light_1.16.0 matrixStats_0.2.1
[10] R.rsp_0.3.6 R.cache_0.3.0 R.filesets_0.8.3
[13] digest_0.4.2 R.utils_1.4.4 R.oo_1.7.3
[16] R.methodsS3_1.2.0

loaded via a namespace (and not attached):
[1] tools_2.11.1

__
R-help@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.





__
R-help@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.


Re: [R] R CMD SHLIB changes function name when compiling

2010-10-08 Thread Steve Pederson
I think I should also add that I have compiled R from source so am 
pretty confident that I have the correct set of Rtools.



On 8/10/2010 8:06 PM, Prof Brian Ripley wrote:

On Fri, 8 Oct 2010, Steve Pederson wrote:


Hi,

I'm trying to write a function in C for implementation with .Call.
When compiling using R CMD SHLIB characters seem to be added to the
function name.

Here's the complete C code from the file summariseMCMC.c:

#includeR.h
#includeRdefines.h
#includeRinternals.h

void summariseMCMC(SEXP data) {

PROTECT(data=AS_NUMERIC(data));
UNPROTECT(1);

}

Then after compiling (R CMD SHLIB summariseMCMC.c)  loading the .dll

dyn.load(C:/R/R-2.11.1/bin/summariseMCMC.dll)
is.loaded(_Z13summariseMCMCP7SEXPREC)
[1] TRUE
is.loaded(summariseMCMC)
[1] FALSE

Just wondering if anyone had any pointers for getting rid of this, or
have I missed something outrageously obvious?


You have. This was not done by'R CMD SHLIB', but by a C++ compiler -- it
is called 'name mangling'. Unfortunately you didn't show us the output
from that command, when the cause would probably have been 'outrageously
obvious'.

The fix is to make sure you use a C compiler to compile C code, and
we've almost no idea why that is not being done on your system.
But as a guess, check that the environment variable CC is not set.



Thanks,

Steve


sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] limma_3.4.4 Biobase_2.8.0 aroma.affymetrix_1.7.0
[4] aroma.apd_0.1.7 affxparser_1.20.0 R.huge_0.2.0
[7] aroma.core_1.7.0 aroma.light_1.16.0 matrixStats_0.2.1
[10] R.rsp_0.3.6 R.cache_0.3.0 R.filesets_0.8.3
[13] digest_0.4.2 R.utils_1.4.4 R.oo_1.7.3
[16] R.methodsS3_1.2.0

loaded via a namespace (and not attached):
[1] tools_2.11.1

__
R-help@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.





__
R-help@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.


Re: [R] R CMD SHLIB changes function name when compiling

2010-10-08 Thread Mike Marchywka










 Date: Sat, 9 Oct 2010 01:21:47 +1030
 From: stephen.peder...@adelaide.edu.au
 To: rip...@stats.ox.ac.uk
 CC: r-help@r-project.org
 Subject: Re: [R] R CMD SHLIB changes function name when compiling

 I think I should also add that I have compiled R from source so am
 pretty confident that I have the correct set of Rtools.

Assuming the problem is name mangling or symbol export,
how about extern C ? I haven't done this lately my memory
is bad but quick goog search suggests this is the header and IIRC
it sound about right.




 On 8/10/2010 8:06 PM, Prof Brian Ripley wrote:
  On Fri, 8 Oct 2010, Steve Pederson wrote:
 
  Hi,
 
  I'm trying to write a function in C for implementation with .Call.
  When compiling using R CMD SHLIB characters seem to be added to the
  function name.
 
  Here's the complete C code from the file summariseMCMC.c:
 
  #include
  #include
  #include
 
  void summariseMCMC(SEXP data) {
 
  PROTECT(data=AS_NUMERIC(data));
  UNPROTECT(1);
 
  }
 
  Then after compiling (R CMD SHLIB summariseMCMC.c)  loading the .dll
 
  dyn.load(C:/R/R-2.11.1/bin/summariseMCMC.dll)
  is.loaded(_Z13summariseMCMCP7SEXPREC)
  [1] TRUE
  is.loaded(summariseMCMC)
  [1] FALSE
 
  Just wondering if anyone had any pointers for getting rid of this, or
  have I missed something outrageously obvious?
 
  You have. This was not done by'R CMD SHLIB', but by a C++ compiler -- it
  is called 'name mangling'. Unfortunately you didn't show us the output
  from that command, when the cause would probably have been 'outrageously
  obvious'.
 
  The fix is to make sure you use a C compiler to compile C code, and
  we've almost no idea why that is not being done on your system.
  But as a guess, check that the environment variable CC is not set.
 
 
  Thanks,
 
  Steve
 
 
  sessionInfo()
  R version 2.11.1 (2010-05-31)
  i386-pc-mingw32
 
  locale:
  [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1
  [3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
  [5] LC_TIME=English_Australia.1252
 
  attached base packages:
  [1] stats graphics grDevices utils datasets methods base
 
  other attached packages:
  [1] limma_3.4.4 Biobase_2.8.0 aroma.affymetrix_1.7.0
  [4] aroma.apd_0.1.7 affxparser_1.20.0 R.huge_0.2.0
  [7] aroma.core_1.7.0 aroma.light_1.16.0 matrixStats_0.2.1
  [10] R.rsp_0.3.6 R.cache_0.3.0 R.filesets_0.8.3
  [13] digest_0.4.2 R.utils_1.4.4 R.oo_1.7.3
  [16] R.methodsS3_1.2.0
 
  loaded via a namespace (and not attached):
  [1] tools_2.11.1
 
  __
  R-help@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.
 
 

 __
 R-help@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.
  
__
R-help@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.


Re: [R] R CMD SHLIB changes function name when compiling

2010-10-08 Thread Prof Brian Ripley
Is the file .c or .C?  You said .c, but then you said a .C file 
worked (which it should not have), and I wonder if you have this 
backwards.


A .c file is C, a .C file is C++ (in R 2.11.1 but not R 2.12.0).

extern C would be required if this were a C++ source, but we were 
told otherwise.


On Sat, 9 Oct 2010, Steve Pederson wrote:


Hi Prof Ripley,

Thanks for the response  the use of the correct terminology. I've checked 
the environment variables  there is none set called CC.


The .dll was definitely compiled using R CMD SHLIB. I'm not quite sure what 
output you're referring to but at the command prompt when I enter:


...\bin R CMD SHLIB summariseMCMC.C

I get the output:

g++ -IC:/R/R-2.11.1/include-02 -Wall summariseMCMC.c 
summariseMCMC.o
g++ -shared -s -static-libgcc -o summariseMCMC.dll tmp.def summariseMCMC.0 
-LC:/R/R-2.11.1/bin -1R


Exactly that -- g++ is a C++ compiler.

Please let me know if I can try anything different provide any more useful 
output.


Another source file I have (runUniformMCMC.C) compiles  runs perfectly using 
the same approach, so I'm rather perplexed as to why this one gets it's name 
mangled. It originally had actual code in it that did useful things, but I 
stripped it back while I was trying to figure out what is happening.


Thanks again,

Steve


On 8/10/2010 8:06 PM, Prof Brian Ripley wrote:

On Fri, 8 Oct 2010, Steve Pederson wrote:


Hi,

I'm trying to write a function in C for implementation with .Call.
When compiling using R CMD SHLIB characters seem to be added to the
function name.

Here's the complete C code from the file summariseMCMC.c:

#includeR.h
#includeRdefines.h
#includeRinternals.h

void summariseMCMC(SEXP data) {

PROTECT(data=AS_NUMERIC(data));
UNPROTECT(1);

}

Then after compiling (R CMD SHLIB summariseMCMC.c)  loading the .dll

dyn.load(C:/R/R-2.11.1/bin/summariseMCMC.dll)
is.loaded(_Z13summariseMCMCP7SEXPREC)
[1] TRUE
is.loaded(summariseMCMC)
[1] FALSE

Just wondering if anyone had any pointers for getting rid of this, or
have I missed something outrageously obvious?


You have. This was not done by'R CMD SHLIB', but by a C++ compiler -- it
is called 'name mangling'. Unfortunately you didn't show us the output
from that command, when the cause would probably have been 'outrageously
obvious'.

The fix is to make sure you use a C compiler to compile C code, and
we've almost no idea why that is not being done on your system.
But as a guess, check that the environment variable CC is not set.



Thanks,

Steve


sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] limma_3.4.4 Biobase_2.8.0 aroma.affymetrix_1.7.0
[4] aroma.apd_0.1.7 affxparser_1.20.0 R.huge_0.2.0
[7] aroma.core_1.7.0 aroma.light_1.16.0 matrixStats_0.2.1
[10] R.rsp_0.3.6 R.cache_0.3.0 R.filesets_0.8.3
[13] digest_0.4.2 R.utils_1.4.4 R.oo_1.7.3
[16] R.methodsS3_1.2.0

loaded via a namespace (and not attached):
[1] tools_2.11.1

__
R-help@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,  rip...@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, UKFax:  +44 1865 272595

__
R-help@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.


Re: [R] R CMD SHLIB changes function name when compiling

2010-10-08 Thread Steve Pederson
It seems that was the problem. My apologies as I was unaware of the 
difference between a .c file  a .C file.


Thanks again for your help,

Steve



On 9/10/2010 1:37 AM, Prof Brian Ripley wrote:

Is the file .c or .C?  You said .c, but then you said a .C file worked
(which it should not have), and I wonder if you have this backwards.

A .c file is C, a .C file is C++ (in R 2.11.1 but not R 2.12.0).

extern C would be required if this were a C++ source, but we were told
otherwise.

On Sat, 9 Oct 2010, Steve Pederson wrote:


Hi Prof Ripley,

Thanks for the response  the use of the correct terminology. I've
checked the environment variables  there is none set called CC.

The .dll was definitely compiled using R CMD SHLIB. I'm not quite sure
what output you're referring to but at the command prompt when I enter:

...\bin R CMD SHLIB summariseMCMC.C

I get the output:

g++ -IC:/R/R-2.11.1/include -02 -Wall summariseMCMC.c summariseMCMC.o
g++ -shared -s -static-libgcc -o summariseMCMC.dll tmp.def
summariseMCMC.0 -LC:/R/R-2.11.1/bin -1R


Exactly that -- g++ is a C++ compiler.


Please let me know if I can try anything different provide any more
useful output.

Another source file I have (runUniformMCMC.C) compiles  runs
perfectly using the same approach, so I'm rather perplexed as to why
this one gets it's name mangled. It originally had actual code in it
that did useful things, but I stripped it back while I was trying to
figure out what is happening.

Thanks again,

Steve


On 8/10/2010 8:06 PM, Prof Brian Ripley wrote:

On Fri, 8 Oct 2010, Steve Pederson wrote:


Hi,

I'm trying to write a function in C for implementation with .Call.
When compiling using R CMD SHLIB characters seem to be added to the
function name.

Here's the complete C code from the file summariseMCMC.c:

#includeR.h
#includeRdefines.h
#includeRinternals.h

void summariseMCMC(SEXP data) {

PROTECT(data=AS_NUMERIC(data));
UNPROTECT(1);

}

Then after compiling (R CMD SHLIB summariseMCMC.c)  loading the .dll

dyn.load(C:/R/R-2.11.1/bin/summariseMCMC.dll)
is.loaded(_Z13summariseMCMCP7SEXPREC)
[1] TRUE
is.loaded(summariseMCMC)
[1] FALSE

Just wondering if anyone had any pointers for getting rid of this, or
have I missed something outrageously obvious?


You have. This was not done by'R CMD SHLIB', but by a C++ compiler -- it
is called 'name mangling'. Unfortunately you didn't show us the output
from that command, when the cause would probably have been 'outrageously
obvious'.

The fix is to make sure you use a C compiler to compile C code, and
we've almost no idea why that is not being done on your system.
But as a guess, check that the environment variable CC is not set.



Thanks,

Steve


sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] limma_3.4.4 Biobase_2.8.0 aroma.affymetrix_1.7.0
[4] aroma.apd_0.1.7 affxparser_1.20.0 R.huge_0.2.0
[7] aroma.core_1.7.0 aroma.light_1.16.0 matrixStats_0.2.1
[10] R.rsp_0.3.6 R.cache_0.3.0 R.filesets_0.8.3
[13] digest_0.4.2 R.utils_1.4.4 R.oo_1.7.3
[16] R.methodsS3_1.2.0

loaded via a namespace (and not attached):
[1] tools_2.11.1

__
R-help@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.









__
R-help@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.