[Rd] Problem using ofstream in C++ class in package for MacOS X
cstrato at aon.at
Thu Feb 8 22:04:14 CET 2007
Ross Boylan wrote:
> On Sun, Feb 04, 2007 at 10:47:37PM +0100, cstrato wrote:
>> Seth Falcon wrote:
>>> cstrato <cstrato at aon.at> writes:
>>>> Thank you for your fast answer.
>>>> Sorrowly, I don´t know how to use a debugger on MacOS X, I am using
>>>> old-style print commands.
>>> You should be able to use gdb on OS X (works for me, YMMV). So you
>>> could try:
>>> R -d gdb
>>> # source a script that causes crash
>>> # back in gdb, use backtrace, etc.
>>> + seth
>> Dear Seth
>> Thank you for this tip, I just tried it and here is the result:
>> Welcome to MyClass
>> > writeFileCpp("myout_fileCpp.txt")
>>  "outfile = myout_fileCpp.txt"
>> Writing file myout_fileCpp.txt using C++ style.
>> Program received signal EXC_BAD_ACCESS, Could not access memory.
>> Reason: KERN_PROTECTION_FAILURE at address: 0x00000006
>> 0x020fe231 in std::ostream::flush (this=0x214f178) at
>> No such file or directory.
>> It seems that it cannot find ostream.tcc, whatever this extension means.
>> Best regards
> I also don't see what the problem is, but have a couple of thoughts.
> Under OS-X there is an environment variable you can define to get the
> dynamic linker to load debug versions of libraries. I can't remember
> what it is, but maybe something like DYLD_DEBUG (but probably DEBUG is
> part of the value of the variable).
> For that, or the tracing above, to be fully informative you need to
> have installed the appropriate debugging libraries and sources.
> You may need to set an explicit source search path in gdb to pick up
> the source files.
> Try stepping through the code from write before the crash to determine
> exactly where it runs into trouble.
> Does the output file you are trying to create exist?
> Unfortunately, none of this really gets at your core bug, but it might
> help track it down.
Thank you, my problem is that I know exactly where the problem is but
not how to solve it.
I have installed R-2.4.1 on three different machines to test the package:
- Intel-Laptop running Fedora Core 4: package is OK
- PPC-PowerBook Titanium OS X 10.4.4: package is OK
- Intel-MacBook Pro Core 2 Duo OS X 10.4.8: C output OK, C++ output
The following code in method WriteFileCpp() works, but gives no result:
The following code in method WriteFileCpp() crashes R:
output << "21" << endl;
It seems that on the Intel-MacBook Pro the operator "<<" is not
recognized, when called
from within my package in R.
In contrast, when compiled as a C++ library, the same code does work on
More information about the R-devel