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

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

Duncan Temple Lang <> wrote:

  dtl> wrote:
>> dyn.load("/opt/fame/timeiq/lib/linux_x86/", local = F)
>> library.dynam("fame", package = "fame")
>> The code in uses functions found in, 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 link against when creating
  dtl> the DLL/SO.  Then you don't have to pollute the
  dtl> global symbol table for the process with
  dtl> and you can use the PACKAGE argument.

Will that work? Some of the functions in get called directly via .C(). How would linking against help when doesn't know what functions in 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 with useDynLib() in the NAMESPACE file
  dtl> and not library.dynam()

As I understand it, useDynLib(fame) is actually a directive that results in 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 mailing list 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 Please read the posting guide before posting to the list.