From tom at levelelimited.com  Thu Oct 26 09:25:19 2006
From: tom at levelelimited.com (tom at levelelimited.com)
Date: Thu, 26 Oct 2006 08:25:19 +0100
Subject: [Rd] Cross-compilation
In-Reply-To: <j7qedl.u1t7jy@webmail.livemail.co.uk>
References: <op.thziv9jjmfjo24@norisk> <200610251910.40831.rdiaz@cnio.es>
	<op.thzmt7scmfjo24@norisk> <j7qedl.u1t7jy@webmail.livemail.co.uk>
Message-ID: <j7qfa7.gagzbc@webmail.livemail.co.uk>

False alarm, those errors were due to the old iostream R.h ordering required -
so not a lead after all.

Tom

tom at levelelimited.com wrote:

> More information for you.
> 
> In order to test some ideas I had I first attempted to compile the gafit
> package which is just a single file - this compiled fine (this is a C
> package).  
> 
> I then added the iostream library to it as so:
> 
> #include <iostream>
> 
> and altered the extension from c to cpp so it would compile as a C++ program
> and I get the following:
> 
> *********************************
>    START OUTPUT
> *********************************
> export
>
PATH=/my/path/RCrossBuild/cross-tools/bin:/my/path/RCrossBuild/cross-tools/mingw32/bin:/usr/local/pgsql/bin:/home/tmccallum/sbin:/usr/java/jdk1.5.0_06/bin:/usr/java/jdk1.5.0_06/jre/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/tmccallum/bin;
> \
> export mypkg=`echo gafittest | cut -d'_' -f1,1`; \
> export mypkg_v=gafittest; \
> cd /my/path/RCrossBuild/pkgsrc; \
> rm -rf $mypkg; \
> tar zxf gafittest.tar.gz; \
> echo ---        ----$mypkg------; \
> cd /my/path/RCrossBuild/WinR/R-2.4.0/src/gnuwin32/; \
> make PKGDIR=/my/path/RCrossBuild/pkgsrc RLIB=/my/path/RCrossBuild/WinRlibs
> STAMP=no pkg-$mypkg; \
> mkdir -p         /my/path/RCrossBuild/WinRlibs; \
> cd /my/path/RCrossBuild/WinRlibs; \
> rm -rf $mypkg_v.zip; \
> zip -rl $mypkg_v.zip $mypkg -x \*.so \*.dll \*.RData \*.rda \*.gz \*.zip
> \*.rds \*.pdf \*.ps;\
> zip -r9 $mypkg_v.zip $mypkg -i \*.so \*.dll \*.RData \*.rda \*.gz \*.zip
> \*.rds \*.pdf \*.ps;\
> rm -rf $mypkg_v
> --- ----gafittest------
> make[1]: Entering directory `/my/path/RCrossBuild/WinR/R-2.4.0/src/gnuwin32'
> 
> ---------- Making package gafittest ------------
>   adding build stamp to DESCRIPTION
>   making DLL ...
> making gafit.d from gafit.cpp
> In file included from
>
/my/path/RCrossBuild/cross-tools/bin/../lib/gcc/i586-mingw32/3.4.5/../../../../include/c++/3.4.5/bits/locale_facets.h:1533,
>                  from
>
/my/path/RCrossBuild/cross-tools/bin/../lib/gcc/i586-mingw32/3.4.5/../../../../include/c++/3.4.5/bits/basic_ios.h:44,
>                  from
>
/my/path/RCrossBuild/cross-tools/bin/../lib/gcc/i586-mingw32/3.4.5/../../../../include/c++/3.4.5/ios:51,
>                  from
>
/my/path/RCrossBuild/cross-tools/bin/../lib/gcc/i586-mingw32/3.4.5/../../../../include/c++/3.4.5/ostream:45,
>                  from
>
/my/path/RCrossBuild/cross-tools/bin/../lib/gcc/i586-mingw32/3.4.5/../../../../include/c++/3.4.5/iostream:45,
>                  from gafit.cpp:22:
>
/my/path/RCrossBuild/cross-tools/bin/../lib/gcc/i586-mingw32/3.4.5/../../../../include/c++/3.4.5/bits/codecvt.h:219:45:
> macro "length" passed 4 arguments, but takes just 1
> make[4]: *** [gafit.d] Error 1
> make[3]: *** [srcDynlib] Error 2
> make[2]: *** [all] Error 2
> make[1]: *** [pkg-gafittest] Error 2
> make[1]: Leaving directory `/my/path/RCrossBuild/WinR/R-2.4.0/src/gnuwin32'
>   adding: gafittest/ (stored 0%)
>   adding: gafittest/DESCRIPTION (deflated 41%)
>   adding: gafittest/Meta/ (stored 0%)
>   adding: gafittest/COPYING (deflated 62%)
>   adding: gafittest/Meta/package.rds (deflated 54%)
> 
> *********************************
>    END OUTPUT
> *********************************
> 
> I have checked the search paths and it is using the includes in gcc 3.4.5
that
> come with mingW32 as the docs say it should.  Line 22 of gafit that it
points
> to is where I include iostream (have tried both <iostream> and "iostream" to
> see if it made any difference).  So I think that the g++ version of mingW32
> may be the problem.
> 
> Any suggestions,
> 
> Tom
> 
> 
> 
> 
> 
> "Tom McCallum" <term at blueyonder.co.uk> wrote:
> 
> > Thanks for your reply, as an example it appears to have difficulty linking
 
> > to even ostream library of the standard C++, as shown below:
> > 
> > /home/tmccallum/ritzel/RItzel/src/Classifier.cpp:209: undefined reference 

> > to `_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc'
> > Classifier.o: In function `operator<<':
> >
>
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../include/c++/4.0.2/ostream:218:
> >  
> > undefined reference to `_ZNSolsEd'
> >
>
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../include/c++/4.0.2/ostream:196:
> >  
> > undefined reference to `_ZNSolsEl'
> > 
> > I am currently working R-2.4.0 as downloaded today.
> > 
> > I know the g++ has gone through some alterations and wondered if you knew 

> > the version of g++ you cross-compiled your package with for comparison -  
> > mine is g++ (GCC) 4.0.2 20051125 (Red Hat 4.0.2-8).
> > 
> > Many thanks
> > 
> > Tom
> > 
> > 
> > On Wed, 25 Oct 2006 18:10:40 +0100, Ramon Diaz-Uriarte <rdiaz at cnio.es>  
> > wrote:
> > 
> > > Dear Tom,
> > >
> > > It has worked for me out-of-the box in at least two times, one a while  
> > > ago
> > > with R-2.2-something and recently with R-2.4.0. In both cases, I was  
> > > running
> > > Debian (with a mix of testing and unstable) on x86. I never had to do
> > > anything, just run the script and at least in one case I did  
> > > crosscompile a
> > > package with C++.
> > >
> > >
> > > R.
> > >
> > > On Wednesday 25 October 2006 18:03, Tom McCallum wrote:
> > >> Hi everyone,
> > >>
> > >> I am trying to cross-compile a package I wrote using the Yan and
Rossini
> > >> tutorial "Building Microsoft Windows versions of R and R packages using
> > >> Intel Linux".  I have got reasonably far with this but when doing the
> > >> linking using the line:
> > >>
> > >> i586-mingw32-g++  -shared -s  -o mylibrary.dll mylibrary.def
mylibrary.o
> > >> mylibrary_res.o  -L/my/path/RCrossBuild/WinR/R-2.4.0/bin -lR
> > >>
> > >> I get lots of these type of messages:
> > >> /my/path/to/mylibrary.cpp:43: undefined reference to
> > >> `_GLOBAL_OFFSET_TABLE_'
> > >>
> > >> and other similar linker errors for virtually every object and command 

> > >> in
> > >> the program.  After some googling I have found that there may be  
> > >> problems
> > >> with the libgcc.a library and its default -fPIC argument during
> > >> compilation.
> > >>
> > >> Has anyone got this tutorial to work and if so how did they overcome  
> > >> this?
> > >>
> > >> I am attempting to do this on Fedora Core 4 on a 32-bit machine, having
> > >> completed all the previous sections of the tutorial for building a
> > >> cross-platform version of R.
> > >>
> > >> Many thanks
> > >>
> > >> Tom
> > >
> > 
> >
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>




[Rd] Cross-compilation
tom at levelelimited.com