problem with dld example

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with dld example

Jeppe Sigbrandt
Hello,

Am interested in using dynamic loading with Octave.
Downloaded, compiled & installed dld-3.3 for Linux a.out.
Tried to compile example program in section 5.8 of documentation:

# g++ -I/mnt/jay/octave-1.1.1/src -I/mnt/jay/octave-1.1.1/liboctave ex_dld.C

Which yields:

ex_dld.C:10: macro `DEFUN_DLD' used with only 6 args

This could be extremely simple - I don't know any c++
- so any suggestions appreciated.  However it seems to me
that DEFUN_DLD defined in defun-dld.h needs 7 arguments
(SFname is missing).  Could this be anything to do with
whether octave is configured with DLD support?
(included the source files since they're very short)
Unfortunatly, can't recompile octave to check above since
my executables refuse to run across solaris-NFS !?

Also, will be upgrading to ELF soon.  Since dld doesn't work
with ELF, will dynamic loading still work with octave?

Regards,
jay

CC to [hidden email] if possible

ps: I am very impressed by octave and am having much trouble
believing its free.  Muchas Muchas Gracias to 'jwe' and contributors.


------- ex_dld.C source follows -------

 #include <iostream.h>

 #include "defun-dld.h"
 #include "tree-const.h"

 DEFUN_DLD ("hello", Fhello, Shello, -1, -1,
  "hello (...)\n\
 \n\
 Print greeting followed by the values of all the arguments passed.\n\
 Returns all the arguments passed.")
 {
       Octave_object retval;
       cerr << "Hello, world!\n";
       int nargin = args.length ();
       for (int i = 1; i < nargin; i++)
         retval (nargin-i-1) = args(i).eval (1);
       return retval;
 }

-------------- defun-dld.h  follows ------

// defun-dld.h                                           -*- C++ -*-
/*
[GPL and jwe copyright snipped]
*/

#if !defined (octave_defun_dld_h)
#define octave_defun_dld_h 1

#if defined (octave_defun_h)
#error defun.h and defun-dld.h both included in same file!
#endif

#include "defun-int.h"

// Define a builtin function that may be loaded dynamically at run
// time.
//
// If Octave is not configured for dynamic linking of builtin
// functions, this is exactly like DEFUN.

#if defined (WITH_DLD) && defined (OCTAVE_LITE) && defined (MAKE_BUILTINS)
#define DEFUN_DLD_BUILTIN(name, fname, sname, nargin_max, nargout_max, doc) \
  BEGIN_INSTALL_BUILTIN \
    DEFINE_FUN_STRUCT (name, 0, sname, nargin_max, nargout_max, 0, doc); \
    install_builtin_function (&sname); \
  END_INSTALL_BUILTIN
#else
#define DEFUN_DLD_BUILTIN(name, fname, sname, nargin_max, nargout_max, doc) \
  DEFUN_INTERNAL (name, fname, sname, nargin_max, nargout_max, 0, doc)
#endif

// Define a function that may be loaded dynamically at run time.
//
// If Octave is not configured for dynamic linking of builtin
// functions, this won't do anything useful.
//
// The forward declaration is for the struct, the second is for the
// definition of the function.

#if ! defined (MAKE_BUILTINS)
#define DEFUN_DLD(name, fname, sname, fsname, nargin_max, nargout_max, doc) \
  DECLARE_FUN (fname); \
  DEFINE_FUN_STRUCT (name, fname, sname, nargin_max, nargout_max, 0, doc); \
  DEFINE_FUN_STRUCT_FUN (sname, fsname) \
  DECLARE_FUN (fname)
#endif

#endif

/*
;;; Local Variables: ***
;;; mode: C++ ***
;;; page-delimiter: "^/\\*" ***
;;; End: ***
*/

Reply | Threaded
Open this post in threaded view
|

problem with dld example

John W. Eaton-6
On  3-Jul-1996, Jeppe Sigbrandt <[hidden email]> wrote:

: Am interested in using dynamic loading with Octave.
: Downloaded, compiled & installed dld-3.3 for Linux a.out.
: Tried to compile example program in section 5.8 of documentation:
:
: # g++ -I/mnt/jay/octave-1.1.1/src -I/mnt/jay/octave-1.1.1/liboctave ex_dld.C
:
: Which yields:
:
: ex_dld.C:10: macro `DEFUN_DLD' used with only 6 args
:
: This could be extremely simple - I don't know any c++
: - so any suggestions appreciated.  However it seems to me
: that DEFUN_DLD defined in defun-dld.h needs 7 arguments
: (SFname is missing).

The documentation is wrong.  The example should begin with

  DEFUN_DLD ("hello", Fhello, Shello, FShello, -1, -1,
    "hello (...)\n

In the next release, this will be simplified to

  DEFUN_DLD (hello, args, nargout,
    "hello (...)"
  {
     ...
  }

: Could this be anything to do with whether octave is configured with
: DLD support?

No, the use of the DEFUN_DLD macro is the same in either case.

: Also, will be upgrading to ELF soon.  Since dld doesn't work
: with ELF, will dynamic loading still work with octave?

No.

The next release of Octave will support dynamic linking on systems
that support either dlopen/dlclose (Solaris, Irix, Linux, Digital
Unix, AIX, etc.) or shl_load/shl_findsym (HP/UX only?).  Support for
dld has been dropped.

jwe