Simon,

The reason I'm using the Makefile is the code which needs to be compiled
under g95. Duncan Temple Lang generously helped me get the package working 
under
linux by using the Makefile. He briefly tried doing it with a Makevars file 
but couldn't get it to
work. 

I tried taking the link command out of my Makefile and using it as a 
Makevars:


F90_FILES=\
dbest_dbase_class.f90 \
...
r_estimate.f90 \


FORTRAN_FILES=\
dgletc.f \
...
mecdf.f

C_FILES=init.c

CFLAGS=-g -fPIC

%.o: %.f90
g95 -c -g $<

%.o: %.f
g95 -c -g $<

%.o: %.c
gcc -c -g $<

---EOF----

It appears to me that a build with Makevars will use gcc-3.3 for linking, 
and completely ignores my f90
files:

gcc-3.3 -bundle -flat_namespace -undefined suppress -L/usr/local/lib -o 
bpkg.so dgletc.o dglfg.o dglfgb.o dmdc.o init.o
mecdf.o-L/usr/local/lib/gcc/powerpc-
apple-darwin6.8/3.4.2 -lg2c -lSystem -framework R

When I try to dyn.load the resulting .so I get:

Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library '/Users/jbremson/dev/bpkg/src/bpkg.so':
dlopen(/Users/jbremson/dev/bpkg/src/bpkg.so, 6): Symbol not found: 
__g95_st_write
Referenced from: /Users/jbremson/dev/bpkg/src/bpkg.so
Expected in: flat namespace

---EOF---

This seems reasonable because gcc-3.3 completed ignored anything having to 
do with g95.



As you might be able to guess I'm new to the process of compiling and 
linking Fortran and C, especially
on the Mac. I'm going to spend some time reading up on makefiles.

One thing to note is that this is research code which will not be publically 
released for at least another year.
Building a highly distributable package is not a priority right now; it just 
needs to work on a few macs for
for now so if it's a bit kludgey that is OK. 

Regards,

Joel Bremson
Graduate Student
UC Davis

On 6/23/05, Simon Urbanek <simon.urbanek@r-project.org> wrote:
> 
> Joel,
> 
> On Jun 23, 2005, at 3:39 PM, Joel Bremson wrote:
> 
> > I have a working package for linux, including fortran 95 code
> > compiled with g95, that I need to port to OS X. The package works
> > on Linux and seems to load on the Mac,but when I try to run a
> > function that calls C or Fortran I'm told that the symbol is not
> > loaded.
> 
> A high-level question first: what are you trying to do here? (I'm
> assuming you're the author of the package - if not, send all this to
> the author ;)). Using a fixed Makefile is a really bad idea, because
> you lose all the flags that R configuration conveniently detected for
> you, so that package is likely to run only on one specific system and
> nowhere else. In most cases you don't need any Makefile at all,
> because R supplies all that is needed. You can still specify any
> additional flags or dependencies using Makevars. Finally, even if you
> have a very complex setting, it's easier to use configure and
> Makevars than building the entire Makefile (which involves using
> autoconf anyway). Actually from the Makefile you provided it seems to
> me that it's entirely superfluous, because you use no complex
> settings at all.
> 
> > I was told to use the .dylib extension instead of .so
> 
> Who told you that? If you used the regular process for compiling
> package code that R provides, you'd see that libraries in packages
> still use .so, because they are loaded using dlopen so the name
> doesn't have to conform to OS' conventions.
> 
> Please consult 'Writing R Extensions' ( http://cran.r-project.org/doc/
> manuals/R-exts.html ) - it provides guidance and examples. Is also
> says "Note that this mechanism [using Makevars] should be general
> enough to eliminate the need for a package-specific Makefile. If such
> a file is to be distributed, considerable care is needed to make it
> general enough to work on all R platforms".
> 
> Cheers,
> Simon
> 
>

	[[alternative HTML version deleted]]

