[Rd] Problems compiling C code on windows
Uwe Ligges
ligges at statistik.uni-dortmund.de
Wed Apr 27 15:59:00 CEST 2005
Victor Trevino wrote:
> Hi all,
>
>
>
> I can't get my C routines running on a windows box. I have no problems at
> all in Linux.
>
>
>
> On windows, I have installed cygwin and the compilation works well but once
> I execute "dyn.load(.)" it hangs whatever I use C/C++ interfaces.
cygwin is not supported. Please read the manuals on how to set upo a
working environment under Windows.
Uwe Ligges
>
>
> In Linux it works wonderful but I need to get this code running on windows
> boxes.
>
> I know that the problem should be something with the dll generation/linkage
> in windows but I can't figure out.
>
>
>
> As a matter of test I did the following C code:
>
>
>
> #include <R.h>
>
> #include <Rinternals.h>
>
> SEXP thisisatest(SEXP);
>
> SEXP thisisatest(SEXP a)
>
> {
>
> long int i;
>
> if (!isReal(a)) printf("Vector should be double.\n");
>
> for (i=LENGTH(a)-1; i >=0; i--) {
>
> REAL(a)[i] = REAL(a)[i] + 1;
>
> }
>
> return (a);
>
> }
>
>
>
>
>
>
>
> Linux output:
>
> R CMD SHLIB thisisthetest.c
>
> gcc -I/usr/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp
> -fPIC -O2 -g -pipe -march=i386 -mcpu=i686 -c thisisthetest.c -o
> thisisthetest.o
>
> g++ -shared -L/usr/local/lib -o thisisthetest.so thisisthetest.o
>
>
>
> In R:
>
>
>>dyn.load("thisisthetest.so")
>
>
>>.Call("thisisatest",5)
>
>
> [1] 6
>
>
>
> [[ WONDERFUL ]]
>
>
>
>
>
>
>
>
>
> Windows output:
>
> L:\R>Rcmd SHLIB thisisthetest.c
>
> making thisisthetest.d from thisisthetest.c
>
> gcc -IC:/PROGRA~1/R/rw2001/include -Wall -O2 -c thisisthetest.c -o
> thisisthetest.o
>
> ar cr thisisthetest.a thisisthetest.o
>
> ranlib thisisthetest.a
>
> gcc --shared -s -o thisisthetest.dll thisisthetest.def thisisthetest.a
> -LC:/PROGRA~1/R/rw2001/src/gnuwin32 -lg2c -lR
>
>
>
> In R:
>
>
>>dyn.load("thisisthetest.dll")
>
>
> [[ IT HANGS ]]
>
>
>
>
>
>
>
> I have tried different combinations in paths (for library search) and
> compiling inside cygwin. no success.
>
>
>
> Any comments are very very very welcome.
>
>
>
>
>
> Thanks !
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list