Re: [Rd] dyn.load and function calls without 'PACKAGE' argument

From: Jeffrey J. Hallman <m1jjh00_at_frb.gov>
Date: Fri 08 Dec 2006 - 20:40:41 GMT


Duncan Temple Lang <duncan@wald.ucdavis.edu> wrote:

  dtl> jhallman@frb.gov wrote:
>> dyn.load("/opt/fame/timeiq/lib/linux_x86/libjchli.so", local = F)
>> library.dynam("fame", package = "fame")
>> The code in fame.so uses functions found in libjchli.so, making the
>> 'local = F' argument in dyn.load() necessary.

  dtl> Well, that is one approach.
  dtl> A more  regular and in most senses "better" approach is to
  dtl> have your fame.so link against libjchli.so when creating
  dtl> the fame.so DLL/SO.  Then you don't have to pollute the
  dtl> global symbol table for the process with libjchli.so
  dtl> and you can use the PACKAGE argument.

Will that work? Some of the functions in libjchli.so get called directly via .C(). How would linking fame.so against libjchli.so help when fame.so doesn't know what functions in libjchli.so I am going to call? Perhaps I don't understand how linking works. Please feel free to enlighten me.

  dtl> That said, the PACKAGE argument is not necessary if you use
  dtl> a NAMESPACE file for the package.
  dtl> Load the fame.so with useDynLib() in the NAMESPACE file
  dtl> and not library.dynam()

As I understand it, useDynLib(fame) is actually a directive that results in fame.so being loaded via library.dynam(). I am using a NAMESPACE, so I will try your advice and thank you for it.

  dtl> And if you explicitly list the routines you want to use
  dtl> in the useDynLib() call, you can refer to them as
  dtl>   .Call(foo, ...)

  dtl> with no quotes, no PACKAGE and you will be able to handle   dtl> multiple versions and provide aliases for the routine names.

What if I don't explicitly list the routines? Many of the routines are only compiled in for Unix, not Windows. Is there a way to use a different useDynLib() directive depending on the operating system?

Jeff



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Dec 09 07:46:05 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 08 Dec 2006 - 22:30:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.