Hello, I used a mac G5, R.2.1.1, and G77 3.4.4 and I would like to use and call a fortran subroutine. The trouble is that it seems I am not able to correctly load the compiled code. Here is what I have done: In the terminal this how I compiled my fortran code: R CMD SHLIB ~/Desktop/Fortan_kmeans/kmeans3.f There is the wrapper I have paste inside de kmeans3.f file: c THIS IS THE WRAPPER subroutine wrapper(n, p, nran, mat, ishort, w, z, + ntran, istand, k1, k2, iassign, iseed) integer n,p,kmax real*8 mat(n,p),sx(kmax,p),sx2(kmax,p),vect(p), + xbar(kmax,p),var(kmax,p),mean(p),coord(10) real*8 D1,Dref,SSE,SSEref,Dvec(kmax),w(p),SST real*8 CH,CHr(kmax),SSEr(kmax),temp integer list(n),howmany(kmax),no(n),nobest(kmax) integer listr(kmax,n),howmanyr(kmax,kmax),nnitr(kmax) integer ishort(p) double precision kmeans, external kmeans call kmeans(n, p, nran, mat, ishort, w, + ntran, istand, k1, k2, iassign, iseed) end c THIS IS THE BEGINNING OF THE ORIGINAL FORTRAN CODE subroutine kmeans(n, p, nran, mat, ishort, w, + ntran, istand, k1, k2, iassign, iseed, CHr, SSEr) ...... Once compiled, in R, I get the following: > dyn.load("/Users/sebas/Desktop/Fortan_kmeans/K-means3.so") > getLoadedDLLs() Filename 1 base 2 /Library/Frameworks/R.framework/Resources/library/grDevices/libs/ grDevices.so 3 /Library/Frameworks/R.framework/Resources/library/stats/ libs/stats.so 4 /Library/Frameworks/R.framework/Resources/library/methods/libs/ methods.so 5 /Users/sebas/Desktop/Fortan_kmeans/kmeans3.so Dynamic.Lookup 1 FALSE 2 FALSE 3 FALSE 4 FALSE 5 TRUE > > is.loaded(symbol.For("/Users/sebas/Desktop/Fortan_kmeans/ kmeans3.so")) [1] FALSE > is.loaded(symbol.For("kmeans3")) [1] FALSE > is.loaded(symbol.For("wrapper")) [1] FALSE Then whatever I write in .Fortran("",...), I always get : Erreur in .Fortran("/Users/sebas/Desktop/Fortan_kmeans/kmeans3.so",... : the function name "Fortran" is absent of the allocation table (this warning was translated from french) So if anyone got a clue, please let me know. I would be more than happy to find and understand what I am doing wrong! Cheers S?bastien Durand
On Wed, 3 Aug 2005, =?iso-8859-1?Q?S=E9bastien_Durand_ wrote:> I used a mac G5, R.2.1.1, and G77 3.4.4 and I would like to use and > call a fortran subroutine. > The trouble is that it seems I am not able to correctly load the > compiled code. > > Here is what I have done: > > In the terminal this how I compiled my fortran code: > > R CMD SHLIB ~/Desktop/Fortan_kmeans/kmeans3.f > > There is the wrapper I have paste inside de kmeans3.f file: > > c THIS IS THE WRAPPER > subroutine wrapper(n, p, nran, mat, ishort, w, z, > + ntran, istand, k1, k2, iassign, iseed) > integer n,p,kmax > real*8 mat(n,p),sx(kmax,p),sx2(kmax,p),vect(p), > + xbar(kmax,p),var(kmax,p),mean(p),coord(10) > real*8 D1,Dref,SSE,SSEref,Dvec(kmax),w(p),SST > real*8 CH,CHr(kmax),SSEr(kmax),temp > integer list(n),howmany(kmax),no(n),nobest(kmax) > integer listr(kmax,n),howmanyr(kmax,kmax),nnitr(kmax) > integer ishort(p) > double precision kmeans, > external kmeans > > call kmeans(n, p, nran, mat, ishort, w, > + ntran, istand, k1, k2, iassign, iseed) > end > c THIS IS THE BEGINNING OF THE ORIGINAL FORTRAN CODE > subroutine kmeans(n, p, nran, mat, ishort, w, > + ntran, istand, k1, k2, iassign, iseed, CHr, SSEr) > ...... > > Once compiled, in R, I get the following: > > > dyn.load("/Users/sebas/Desktop/Fortan_kmeans/K-means3.so") > > getLoadedDLLs() > > Filename > 1 > base > 2 /Library/Frameworks/R.framework/Resources/library/grDevices/libs/ > grDevices.so > 3 /Library/Frameworks/R.framework/Resources/library/stats/ > libs/stats.so > 4 /Library/Frameworks/R.framework/Resources/library/methods/libs/ > methods.so > 5 /Users/sebas/Desktop/Fortan_kmeans/kmeans3.so > > Dynamic.Lookup > 1 FALSE > 2 FALSE > 3 FALSE > 4 FALSE > 5 TRUE > > > > is.loaded(symbol.For("/Users/sebas/Desktop/Fortan_kmeans/ > kmeans3.so")) > [1] FALSE > > is.loaded(symbol.For("kmeans3")) > [1] FALSE > > is.loaded(symbol.For("wrapper")) > [1] FALSE > > Then whatever I write in .Fortran("",...), I always get : > Erreur in .Fortran("/Users/sebas/Desktop/Fortan_kmeans/kmeans3.so",... : > the function name "Fortran" is absent of the allocation table > (this warning was translated from french)Shouldn't that be .Fortran("wrapper", <arglist>) or something to that effect? I'm surprised that a null string didn't crash the program. Might want to look into R's registration tables as well. That way you might get some additional debugging help. ---------------------------------------------------------- SIGSIG -- signature too long (core dumped)
Thanks for your help, I had read those web pages already, and the post you referred to already. So I will try to give more details to what I have done till now First I must mention again that I am using a mac under tiger. So I am using .so files. My fortran file is called kmeans.f, and my subroutine or wrapper I named it "wrapper" There is my first line of code subroutine wrapper(n, p, nran, mat, ishort, w, z, ntran, istand, k1, k2, iassign, iseed) In the terminal: R CMD SHLIB ~/Desktop/Fortan_kmeans/kmeans3.fg77 -fno-common -g -O2 -c /Users/sebas/Desktop/Fortan_kmeans/ kmeans3.f -o /Users/sebas/Desktop/Fortan_kmeans/kmeans3.o gcc-3.3 -bundle -flat_namespace -undefined suppress -L/usr/ local/lib -o /Users/sebas/Desktop/Fortan_kmeans/kmeans3.so /Users/sebas/ Desktop/Fortan_kmeans/kmeans3.o -L/usr/local/lib/gcc/powerpc-apple-darwin6.8/3.4.2 -lg2c - lSystem -framework R The files append to compile without any warnings. In R: > dyn.load("/Users/sebas/Desktop/Fortan_kmeans/kmeans3.so") > getLoadedDLLs() Filename base base grDevices /Library/Frameworks/R.framework/Resources/library/grDevices/ libs/grDevices.so stats /Library/Frameworks/R.framework/Resources/library/ stats/libs/stats.so methods /Library/Frameworks/R.framework/Resources/library/ methods/libs/methods.so kmeans3 /Users/sebas/Desktop/ Fortan_kmeans/kmeans3.so Dynamic.Lookup base FALSE grDevices FALSE stats FALSE methods FALSE kmeans3 TRUE Dyn.load seems to work since if I type in getLoadedDLLs() I can see the link. > zozo=.Fortran(symbol.For("wrapper"),n=as.integer(n), p=as.integer (p), nran=as.integer(nran), mat=as.matrix(mat), ishort=as.vector (ishort), w=as.vector(w),ntran=as.integer(ntran), istand=as.integer (istand), k1=as.integer(k1), k2=as.integer(k2), iassign=as.integer (iassign), iseed=as.integer(iseed)) Erreur dans .Fortran(symbol.For("wrapper"), n = as.integer(n), p = as.integer(p), : nom de fonction "Fortran" absent de la table d'allocation Even so I am using in the name parameter of the .Fortran function, "wrapper", "kmeans3", "wrapper_" or "kmeans3_" I always get the same error call telling me that the fonction "Fortran" is not in the allocation table That is where I am at now, it has been 4 days I am digging into docs but I haven't been able to find what I am doing wrong. R is so great, I got tons of Fortran lines and subroutine to implement in R but I guess I am missing a little thing to make it work and now I really don't have a cue how to solve that problem. Cheers I will be anxiously waiting for any reply Sébastien> > If I understand correctly, you used > .Fortran("wrapper",....) > > The problem might be that the function name ("wrapper") was changed > in the > compilation of the code! See the mail bellow for clues (a previous > post on > R-help by Duncan Murdoch) > > Natalie Hawkins wrote: > > Using R 2.0.1 on Windows XP, I am getting an error > > msg: > > > > Error in .Fortran("conic", nxy = nxy, npt = npt, CP > > cp, EP1 = ep1, EP2 = ep2, : > > > > Fortran function name not in load table > > > > I am wondering if there is a way to see what function > > names are in the load table? Maybe the function name > > has been altered? > > You need to look at the DLL to see what name it is exporting. I > believe > R would be looking for "conic_". If your Fortran compiler doesn't > append underscores, you'll get this error. > > You might want to look at this page > > http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/ > index.html#badname > > or this one > > http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/ > fortran.html > > for more help. > > Duncan Murdoch[[alternative HTML version deleted]]
At the beginning I was not using symbol.For(), and whatever I add a "_" or not e.g.: .Fortran("wrapper",... I get the same error Sebastien> You want to just say: > > .Fortran("wrapper", ... > > not > > .Fortran(symbol.For("wrapper"), ... > > Patrick Burns > patrick@burns-stat.com > +44 (0)20 8525 0696 > http://www.burns-stat.com > (home of S Poetry and "A Guide for the Unwilling S User") > > Sébastien Durand wrote: > > >> Thanks for your help, >> >> I had read those web pages already, and the post you referred to >> already. >> >> So I will try to give more details to what I have done till now >> >> First I must mention again that I am using a mac under tiger. So >> I am using .so files. >> >> My fortran file is called kmeans.f, and my subroutine or wrapper >> I named it "wrapper" >> >> There is my first line of code >> >> subroutine wrapper(n, p, nran, mat, ishort, w, z, ntran, >> istand, k1, k2, iassign, iseed) >> >> In the terminal: >> R CMD SHLIB ~/Desktop/Fortan_kmeans/kmeans3.fg77 >> -fno-common -g -O2 -c /Users/sebas/Desktop/Fortan_kmeans/ >> kmeans3.f -o /Users/sebas/Desktop/Fortan_kmeans/kmeans3.o >> gcc-3.3 -bundle -flat_namespace -undefined suppress -L/ >> usr/ local/lib -o >> /Users/sebas/Desktop/Fortan_kmeans/kmeans3.so /Users/ >> sebas/ Desktop/Fortan_kmeans/kmeans3.o >> -L/usr/local/lib/gcc/powerpc-apple-darwin6.8/3.4.2 -lg2c - >> lSystem -framework R >> >> The files append to compile without any warnings. >> >> In R: >> >> > dyn.load("/Users/sebas/Desktop/Fortan_kmeans/kmeans3.so") >> > getLoadedDLLs() >> >> Filename >> base >> base >> grDevices /Library/Frameworks/R.framework/Resources/library/ >> grDevices/ libs/grDevices.so >> stats /Library/Frameworks/R.framework/Resources/ >> library/ stats/libs/stats.so >> methods /Library/Frameworks/R.framework/Resources/library/ >> methods/libs/methods.so >> kmeans3 /Users/sebas/Desktop/ >> Fortan_kmeans/kmeans3.so >> Dynamic.Lookup >> base FALSE >> grDevices FALSE >> stats FALSE >> methods FALSE >> kmeans3 TRUE >> >> >> Dyn.load seems to work since if I type in getLoadedDLLs() I can >> see the link. >> >> > zozo=.Fortran(symbol.For("wrapper"),n=as.integer(n), >> p=as.integer (p), nran=as.integer(nran), mat=as.matrix(mat), >> ishort=as.vector (ishort), w=as.vector(w),ntran=as.integer(ntran), >> istand=as.integer (istand), k1=as.integer(k1), k2=as.integer(k2), >> iassign=as.integer (iassign), iseed=as.integer(iseed)) >> Erreur dans .Fortran(symbol.For("wrapper"), n = as.integer(n), p >> = as.integer(p), : >> nom de fonction "Fortran" absent de la table d'allocation >> >> Even so I am using in the name parameter of the .Fortran >> function, "wrapper", "kmeans3", "wrapper_" or "kmeans3_" >> >> I always get the same error call telling me that the fonction >> "Fortran" is not in the allocation table >> >> That is where I am at now, it has been 4 days I am digging into >> docs but I haven't been able to find what I am doing wrong. >> >> R is so great, I got tons of Fortran lines and subroutine to >> implement in R but I guess I am missing a little thing to make it >> work and now I really don't have a cue how to solve that problem. >> >> Cheers >> >> I will be anxiously waiting for any reply >> >> Sébastien >> >> >> >> >>> If I understand correctly, you used >>> .Fortran("wrapper",....) >>> >>> The problem might be that the function name ("wrapper") was >>> changed in the >>> compilation of the code! See the mail bellow for clues (a >>> previous post on >>> R-help by Duncan Murdoch) >>> >>> Natalie Hawkins wrote: >>> >>> >>>> Using R 2.0.1 on Windows XP, I am getting an error >>>> msg: >>>> >>>> Error in .Fortran("conic", nxy = nxy, npt = npt, CP >>>> cp, EP1 = ep1, EP2 = ep2, : >>>> >>>> Fortran function name not in load table >>>> >>>> I am wondering if there is a way to see what function >>>> names are in the load table? Maybe the function name >>>> has been altered? >>>> >>>> >>> You need to look at the DLL to see what name it is exporting. I >>> believe >>> R would be looking for "conic_". If your Fortran compiler doesn't >>> append underscores, you'll get this error. >>> >>> You might want to look at this page >>> >>> http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/ >>> index.html#badname >>> >>> or this one >>> >>> http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/ >>> fortran.html >>> >>> for more help. >>> >>> Duncan Murdoch >>> >>> >> >> [[alternative HTML version deleted]] >> >> >> --------------------------------------------------------------------- >> --- >> >> ______________________________________________ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> > >[[alternative HTML version deleted]]
Ok, Dear all, I have state previously, I am using mac os X tiger on a g5, using the last version of R 2.1.1 When I type in the terminal nm -g ~/Desktop/Fortan_kmeans/kmeans3.so or nm /Users/sebas/Desktop/Fortan_kmeans/kmeans3.so | grep ' T ' Nothing appears on my screen When I type nm ~/Desktop/Fortan_kmeans/kmeans3.so this is what I get: 00000fe0 t __dyld_func_lookup 00000000 t __mh_bundle_header 00001000 d dyld__mh_bundle_header 00001008 s dyld_func_lookup_pointer 00001004 s dyld_lazy_symbol_binding_entry_point 00000fb0 t dyld_stub_binding_helper By the way, yes I have tried is.loaded("wrapper") ? And is always return FALSE S.
Dear all, Since the command you ask me to type doesn't show anything Here some more information, on my system and on the foo.so compiled file I am using g77 version 3.4.4 Configured with: ../gcc/configure -- enable-threads=posix --enable-languages=f77 I am using gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061) Configured with: /private/var/tmp/gcc/gcc-4061.obj~8/src/ configure --disable-checking --prefix=/usr --mandir=/share/man -- enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^ +.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/gcc/darwin/4.0/c++ -- build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 -- target=powerpc-apple-darwin8 I don't know if this can be of any help to you but there is again how I compile the foo.f Double-G5:~ sebas$ R CMD SHLIB ~/Desktop/Fortan_kmeans/kmeans3.f g77 -fno-common -g -O2 -c /Users/sebas/Desktop/ Fortan_kmeans/kmeans3.f -o /Users/sebas/Desktop/Fortan_kmeans/kmeans3.o gcc-3.3 -bundle -flat_namespace -undefined suppress -L/usr/ local/lib -o /Users/sebas/Desktop/Fortan_kmeans/kmeans3.so /Users/ sebas/Desktop/Fortan_kmeans/kmeans3.o -L/usr/local/lib/gcc/powerpc- apple-darwin6.8/3.4.2 -lg2c -lSystem -framework R There is all the info about the foo.so file using nm -a option instead of -g: Double-G5:~ sebas$ nm -a ~/Desktop/Fortan_kmeans/kmeans3.so 00000fe4 - 01 0114 SLINE 00000fb0 - 01 0000 SO 00000fd8 - 01 010d SLINE 00000fdc - 01 010e SLINE 00000fe0 - 01 010f SLINE 00000fec - 01 0116 SLINE 00000fe8 - 01 0115 SLINE 00001000 - 01 0000 SO 00001000 - 01 011b SLINE 00000ffc - 01 011a SLINE 00000ff8 - 01 0119 SLINE 00000fb4 - 01 0104 SLINE 00000fb8 - 01 0105 SLINE 00000fbc - 01 0106 SLINE 00000fc0 - 01 0107 SLINE 00000fc4 - 01 0108 SLINE 00000ff4 - 01 0118 SLINE 00000fc8 - 01 0109 SLINE 00000fcc - 01 010a SLINE 00000fd0 - 01 010b SLINE 00000fd4 - 01 010c SLINE 00000ff0 - 01 0117 SLINE 00000fb0 - 01 0000 SOL /SourceCache/Csu/Csu-57// 00000fb0 - 01 0000 SOL /SourceCache/Csu/Csu-57/bundle1.s 00000fb0 - 01 0000 SOL /SourceCache/Csu/Csu-57/bundle1.s 00000fb0 - 01 0000 SOL /SourceCache/Csu/Csu-57/bundle1.s 00000fb0 - 01 0000 SO /Users/sebas/ 00000fb0 - 01 0000 SO /Users/sebas/Desktop/Fortan_kmeans/kmeans3.f 00000fb0 - 01 0000 SOL <built-in> 00000fb0 - 01 0000 SOL <command line> 00000fe0 t __dyld_func_lookup 00000fe0 - 01 0113 FUN __dyld_func_lookup:F3 00000000 - 00 0000 LSYM __g77_f2c_address:t(0,10)=*(0,11)=@s8;r (0,11);-128;127; 00000000 - 00 0000 LSYM __g77_f2c_complex:t(0,7)=R3;8;0; 00000000 - 00 0000 LSYM __g77_f2c_doublecomplex:t(0,6)=R3;16;0; 00000000 - 00 0000 LSYM __g77_f2c_doublereal:t(0,8)=r(0,0);8;0; 00000000 - 00 0000 LSYM __g77_f2c_flag:t(0,3)=r (0,3);-2147483648;2147483647; 00000000 - 00 0000 LSYM __g77_f2c_ftnint:t(0,1)=r (0,1);-2147483648;2147483647; 00000000 - 00 0000 LSYM __g77_f2c_ftnlen:t(0,2)=r (0,2);-2147483648;2147483647; 00000000 - 00 0000 LSYM __g77_f2c_integer:t(0,12)=r (0,12);-2147483648;2147483647; 00000000 - 00 0000 LSYM __g77_f2c_logical:t(0,4)=r (0,4);-2147483648;2147483647; 00000000 - 00 0000 LSYM __g77_f2c_longint:t(0,5)=@s64;r(0,5); 001000000000000000000000;000777777777777777777777; 00000000 - 00 0000 LSYM __g77_f2c_real:t(0,9)=r(0,0);4;0; 00000000 t __mh_bundle_header 00000000 - 00 0000 LSYM byte:t(0,26)=@s8;r(0,26);-128;127; 00000000 - 00 0000 LSYM char:t(0,46)=@s8;r(0,46);0;255; 00000000 - 00 0000 LSYM char:t2=r2;0;127; 00000000 - 00 0000 LSYM complex double:t(0,31)=R3;16;0; 00000000 - 00 0000 LSYM complex float:t(0,32)=R3;8;0; 00000000 - 00 0000 LSYM complex int:t(0,33)=s8real:(0,34)=r (0,34);-2147483648;2147483647;,0,32;imag:(0,34),32,32;; 00000000 - 00 0000 LSYM complex long double:t(0,30)=R3;16;0; 00000000 - 00 0000 LSYM complex:t(0,14)=R3;8;0; 00000000 - 00 0000 LSYM double complex:t(0,13)=R3;16;0; 00000000 - 00 0000 LSYM double precision:t(0,15)=r(0,0);8;0; 00000000 - 00 0000 LSYM double:t(0,36)=r(0,34);8;0; 00001000 d dyld__mh_bundle_header 00001008 s dyld_func_lookup_pointer 00001004 s dyld_lazy_symbol_binding_entry_point 00000fb0 t dyld_stub_binding_helper 00000fb0 - 01 0103 FUN dyld_stub_binding_helper:F3 00000000 - 00 0000 LSYM float:t(0,37)=r(0,34);4;0; 00000000 - 00 0000 OPT gcc2_compiled. 00000000 - 00 0000 LSYM int:t(0,34) 00000000 - 00 0000 LSYM int:t1=r1;-2147483648;2147483647; 00000000 - 00 0000 LSYM integer4:t(0,22)=@s64;r(0,22); 001000000000000000000000;000777777777777777777777; 00000000 - 00 0000 LSYM integer:t(0,28)=r(0,28);-2147483648;2147483647; 00000000 - 00 0000 LSYM logical2:t(0,19)=@s8;r(0,19);-128;127; 00000000 - 00 0000 LSYM logical3:t(0,18)=@s16;r(0,18);-32768;32767; 00000000 - 00 0000 LSYM logical4:t(0,17)=@s64;r(0,17); 001000000000000000000000;000777777777777777777777; 00000000 - 00 0000 LSYM logical:t(0,20)=r(0,20);-2147483648;2147483647; 00000000 - 00 0000 LSYM long double:t(0,35)=r(0,34);8;0; 00000000 - 00 0000 LSYM long int:t(0,45)=r (0,45);-2147483648;2147483647; 00000000 - 00 0000 LSYM long long int:t(0,42)=@s64;r(0,42); 001000000000000000000000;000777777777777777777777; 00000000 - 00 0000 LSYM long long unsigned int:t(0,41)=@s64;r(0,41); 000000000000000000000000;001777777777777777777777; 00000000 - 00 0000 LSYM long unsigned int:t(0,43)=r(0,43); 000000000000000000000000;000000000000037777777777; 00000000 - 00 0000 LSYM real:t(0,16)=r(0,0);4;0; 00000000 - 00 0000 LSYM short int:t(0,40)=@s16;r(0,40);-32768;32767; 00000000 - 00 0000 LSYM short unsigned int:t(0,39)=@s16;r(0,39); 0;65535; 00000000 - 00 0000 LSYM signed char:t(0,11) 00000000 - 00 0000 LSYM unsigned byte:t(0,25)=@s8;r(0,25);0;255; 00000000 - 00 0000 LSYM unsigned char:t(0,38)=@s8;r(0,38);0;255; 00000000 - 00 0000 LSYM unsigned int:t(0,44)=r(0,44); 000000000000000000000000;000000000000037777777777; 00000000 - 00 0000 LSYM unsigned word:t(0,23)=@s16;r(0,23);0;65535; 00000000 - 00 0000 LSYM unsigned4:t(0,21)=@s64;r(0,21); 000000000000000000000000;001777777777777777777777; 00000000 - 00 0000 LSYM unsigned:t(0,27)=r(0,27); 000000000000000000000000;000000000000037777777777; 00000000 - 00 0000 LSYM void:t(0,29)=(0,29) 00000000 - 00 0000 LSYM void:t3=3 00000000 - 00 0000 LSYM word:t(0,24)=@s16;r(0,24);-32768;32767; 00000fb0 - 01 0000 SO {standard input} Double-G5:~ sebas$ S.
Ok, I am presently updating my system. How do you set setenv gcc /usr/local/bin/gfortran. Using bash. Then I will the command to compile the foo.f file been the same! I guess so S.> > also gcc 4061 is a bit old -- the tiger update in 10.4.2 was > 50xx, i think, cvs is up to apple build 5217 and is now > gcc-4.0.1. > > -- jan > > On Aug 4, 2005, at 8:25 , S?bastien Durand wrote: > > >> Dear all, >> >> Since the command you ask me to type doesn't show anything >> Here some more information, on my system and on the foo.so >> compiled file >> >> I am using g77 version 3.4.4 Configured with: ../gcc/configure -- >> enable-threads=posix --enable-languages=f77 >> >> I am using gcc version 4.0.0 20041026 (Apple Computer, Inc. build >> 4061) >> Configured with: /private/var/tmp/gcc/gcc-4061.obj~8/src/ >> configure --disable-checking --prefix=/usr --mandir=/share/man -- >> enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^ >> +.-]*$/s/$/-4.0/ >> --with-gxx-include-dir=/include/gcc/darwin/4.0/c++ -- >> build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 -- >> target=powerpc-apple-darwin8 >> >> I don't know if this can be of any help to you but there is again how >> I compile the foo.f >> >> Double-G5:~ sebas$ R CMD SHLIB ~/Desktop/Fortan_kmeans/kmeans3.f >> g77 -fno-common -g -O2 -c /Users/sebas/Desktop/ >> Fortan_kmeans/kmeans3.f -o /Users/sebas/Desktop/Fortan_kmeans/ >> kmeans3.o >> gcc-3.3 -bundle -flat_namespace -undefined suppress -L/usr/ >> local/lib -o /Users/sebas/Desktop/Fortan_kmeans/kmeans3.so /Users/ >> sebas/Desktop/Fortan_kmeans/kmeans3.o -L/usr/local/lib/gcc/powerpc- >> apple-darwin6.8/3.4.2 -lg2c -lSystem -framework R >> >> >> There is all the info about the foo.so file using nm -a option >> instead of -g: >> >> >> Double-G5:~ sebas$ nm -a ~/Desktop/Fortan_kmeans/kmeans3.so >> 00000fe4 - 01 0114 SLINE >> 00000fb0 - 01 0000 SO >> 00000fd8 - 01 010d SLINE >> 00000fdc - 01 010e SLINE >> 00000fe0 - 01 010f SLINE >> 00000fec - 01 0116 SLINE >> 00000fe8 - 01 0115 SLINE >> 00001000 - 01 0000 SO >> 00001000 - 01 011b SLINE >> 00000ffc - 01 011a SLINE >> 00000ff8 - 01 0119 SLINE >> 00000fb4 - 01 0104 SLINE >> 00000fb8 - 01 0105 SLINE >> 00000fbc - 01 0106 SLINE >> 00000fc0 - 01 0107 SLINE >> 00000fc4 - 01 0108 SLINE >> 00000ff4 - 01 0118 SLINE >> 00000fc8 - 01 0109 SLINE >> 00000fcc - 01 010a SLINE >> 00000fd0 - 01 010b SLINE >> 00000fd4 - 01 010c SLINE >> 00000ff0 - 01 0117 SLINE >> 00000fb0 - 01 0000 SOL /SourceCache/Csu/Csu-57// >> 00000fb0 - 01 0000 SOL /SourceCache/Csu/Csu-57/bundle1.s >> 00000fb0 - 01 0000 SOL /SourceCache/Csu/Csu-57/bundle1.s >> 00000fb0 - 01 0000 SOL /SourceCache/Csu/Csu-57/bundle1.s >> 00000fb0 - 01 0000 SO /Users/sebas/ >> 00000fb0 - 01 0000 SO /Users/sebas/Desktop/Fortan_kmeans/kmeans3.f >> 00000fb0 - 01 0000 SOL <built-in> >> 00000fb0 - 01 0000 SOL <command line> >> 00000fe0 t __dyld_func_lookup >> 00000fe0 - 01 0113 FUN __dyld_func_lookup:F3 >> 00000000 - 00 0000 LSYM __g77_f2c_address:t(0,10)=*(0,11)=@s8;r >> (0,11);-128;127; >> 00000000 - 00 0000 LSYM __g77_f2c_complex:t(0,7)=R3;8;0; >> 00000000 - 00 0000 LSYM __g77_f2c_doublecomplex:t(0,6)=R3;16;0; >> 00000000 - 00 0000 LSYM __g77_f2c_doublereal:t(0,8)=r(0,0);8;0; >> 00000000 - 00 0000 LSYM __g77_f2c_flag:t(0,3)=r >> (0,3);-2147483648;2147483647; >> 00000000 - 00 0000 LSYM __g77_f2c_ftnint:t(0,1)=r >> (0,1);-2147483648;2147483647; >> 00000000 - 00 0000 LSYM __g77_f2c_ftnlen:t(0,2)=r >> (0,2);-2147483648;2147483647; >> 00000000 - 00 0000 LSYM __g77_f2c_integer:t(0,12)=r >> (0,12);-2147483648;2147483647; >> 00000000 - 00 0000 LSYM __g77_f2c_logical:t(0,4)=r >> (0,4);-2147483648;2147483647; >> 00000000 - 00 0000 LSYM __g77_f2c_longint:t(0,5)=@s64;r(0,5); >> 001000000000000000000000;000777777777777777777777; >> 00000000 - 00 0000 LSYM __g77_f2c_real:t(0,9)=r(0,0);4;0; >> 00000000 t __mh_bundle_header >> 00000000 - 00 0000 LSYM byte:t(0,26)=@s8;r(0,26);-128;127; >> 00000000 - 00 0000 LSYM char:t(0,46)=@s8;r(0,46);0;255; >> 00000000 - 00 0000 LSYM char:t2=r2;0;127; >> 00000000 - 00 0000 LSYM complex double:t(0,31)=R3;16;0; >> 00000000 - 00 0000 LSYM complex float:t(0,32)=R3;8;0; >> 00000000 - 00 0000 LSYM complex int:t(0,33)=s8real:(0,34)=r >> (0,34);-2147483648;2147483647;,0,32;imag:(0,34),32,32;; >> 00000000 - 00 0000 LSYM complex long double:t(0,30)=R3;16;0; >> 00000000 - 00 0000 LSYM complex:t(0,14)=R3;8;0; >> 00000000 - 00 0000 LSYM double complex:t(0,13)=R3;16;0; >> 00000000 - 00 0000 LSYM double precision:t(0,15)=r(0,0);8;0; >> 00000000 - 00 0000 LSYM double:t(0,36)=r(0,34);8;0; >> 00001000 d dyld__mh_bundle_header >> 00001008 s dyld_func_lookup_pointer >> 00001004 s dyld_lazy_symbol_binding_entry_point >> 00000fb0 t dyld_stub_binding_helper >> 00000fb0 - 01 0103 FUN dyld_stub_binding_helper:F3 >> 00000000 - 00 0000 LSYM float:t(0,37)=r(0,34);4;0; >> 00000000 - 00 0000 OPT gcc2_compiled. >> 00000000 - 00 0000 LSYM int:t(0,34) >> 00000000 - 00 0000 LSYM int:t1=r1;-2147483648;2147483647; >> 00000000 - 00 0000 LSYM integer4:t(0,22)=@s64;r(0,22); >> 001000000000000000000000;000777777777777777777777; >> 00000000 - 00 0000 LSYM integer:t(0,28)=r >> (0,28);-2147483648;2147483647; >> 00000000 - 00 0000 LSYM logical2:t(0,19)=@s8;r(0,19);-128;127; >> 00000000 - 00 0000 LSYM logical3:t(0,18)=@s16;r(0,18);-32768;32767; >> 00000000 - 00 0000 LSYM logical4:t(0,17)=@s64;r(0,17); >> 001000000000000000000000;000777777777777777777777; >> 00000000 - 00 0000 LSYM logical:t(0,20)=r >> (0,20);-2147483648;2147483647; >> 00000000 - 00 0000 LSYM long double:t(0,35)=r(0,34);8;0; >> 00000000 - 00 0000 LSYM long int:t(0,45)=r >> (0,45);-2147483648;2147483647; >> 00000000 - 00 0000 LSYM long long int:t(0,42)=@s64;r(0,42); >> 001000000000000000000000;000777777777777777777777; >> 00000000 - 00 0000 LSYM long long unsigned int:t(0,41)=@s64;r(0,41); >> 000000000000000000000000;001777777777777777777777; >> 00000000 - 00 0000 LSYM long unsigned int:t(0,43)=r(0,43); >> 000000000000000000000000;000000000000037777777777; >> 00000000 - 00 0000 LSYM real:t(0,16)=r(0,0);4;0; >> 00000000 - 00 0000 LSYM short int:t(0,40)=@s16;r(0,40);-32768;32767; >> 00000000 - 00 0000 LSYM short unsigned int:t(0,39)=@s16;r(0,39); >> 0;65535; >> 00000000 - 00 0000 LSYM signed char:t(0,11) >> 00000000 - 00 0000 LSYM unsigned byte:t(0,25)=@s8;r(0,25);0;255; >> 00000000 - 00 0000 LSYM unsigned char:t(0,38)=@s8;r(0,38);0;255; >> 00000000 - 00 0000 LSYM unsigned int:t(0,44)=r(0,44); >> 000000000000000000000000;000000000000037777777777; >> 00000000 - 00 0000 LSYM unsigned word:t(0,23)=@s16;r(0,23);0;65535; >> 00000000 - 00 0000 LSYM unsigned4:t(0,21)=@s64;r(0,21); >> 000000000000000000000000;001777777777777777777777; >> 00000000 - 00 0000 LSYM unsigned:t(0,27)=r(0,27); >> 000000000000000000000000;000000000000037777777777; >> 00000000 - 00 0000 LSYM void:t(0,29)=(0,29) >> 00000000 - 00 0000 LSYM void:t3=3 >> 00000000 - 00 0000 LSYM word:t(0,24)=@s16;r(0,24);-32768;32767; >> 00000fb0 - 01 0000 SO {standard input} >> Double-G5:~ sebas$ >> >> S. >> >> ______________________________________________ >> R-devel at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> >> > > =========================================================> Jan de Leeuw, 11667 Steinhoff Rd, Frazier Park, CA 93225, 661-245-1725 > =========================================================> Und die Einen sind im Dunkeln > Und die Andern sind im Licht > Und man siehe die im Lichte > Die im Dunklen sieht man nicht > > Brecht > > > >
On 04/08/2005, at 8:00 PM, Sebastien Durand wrote:> I used a mac G5, R.2.1.1, and G77 3.4.4 and I would like to use and > call a fortran subroutine. > The trouble is that it seems I am not able to correctly load the > compiled code..................> base > 2 /Library/Frameworks/R.framework/Resources/library/grDevices/libs/ > grDevices.so > 3 /Library/Frameworks/R.framework/Resources/library/stats/ > libs/stats.so > 4 /Library/Frameworks/R.framework/Resources/library/methods/libs/ > methods.so > 5 /Users/sebas/Desktop/Fortan_kmeans/kmeans3.so > > Dynamic.Lookup > 1 FALSE > 2 FALSE > 3 FALSE > 4 FALSE > 5 TRUEI really wish someone would make these issues clear in MacOS R documentation. MacOS X 10.3 Panther uses gcc-3.3 as its default compiler. The R binary is built with gcc-3.3 and g77 3.4 so that it will run on Panther. MacOS X 10.4 Tiger uses gcc-4.00 as its default compiler. This causes two problems. 1. Fortran objects built with g77 cannot be linked with C/C++ objects built with gcc-4.0. So an R package with a mixture of C and Fortran code will very likely fail at some point. 2. Even if you specifically invoke gcc-3.3 and g77 the code will still fail to link because it needs a symlink /usr/lib/ libcc_dynamic.dylib which points to libgcc.a. This link is missing if the default gcc-4.0 is the selected compiler. (It is missing because it does not work with gcc-4). If you want to build Fortran source packages on Tiger using the R binary distribution, you need to to do 'sudo gcc_select 3.3' That command will make gcc-3.3 the default compiler and reinstate the symlink, which recreates the environment in which the R binary was built. You can always go back to gcc-4.0 with 'sudo gcc_select 4.0'. Bill Northcott