comp.lang.ada
 help / color / mirror / Atom feed
* Help linking to Octave (mathematical) functions
@ 2014-12-19 21:31 Jerry
  2014-12-26 11:54 ` Blady
  0 siblings, 1 reply; 5+ messages in thread
From: Jerry @ 2014-12-19 21:31 UTC (permalink / raw)


Sorry for the long post.

I use GNAT on OS X 10.9.4. I'm trying to bind to a "loadable function" in Octave, specifically the modified Bessel function of the second kind which, using nm, appears to be in an .oct file at

/opt/local/lib/octave/3.6.4/oct/x86_64-apple-darwin13.3.0/besselj.oct

and not having any luck. (Several kinds of Bessel functions seem to be stored in besselj.oct.)

.oct files are described here

http://octave.sourceforge.net/coda/c58.html

and are said to be shared libraries or shared objects.

I have successfully bound to other Octave functions which are called "built-in" and are found on my machine at 

/opt/local/lib/octave/3.6.4/liboctave.dylib

The gpr library file that I use for the "built-in" functions and that works is this:

library project Octave_Library is
    for Externally_Built use "true";
    for Library_Dir use "/opt/local/lib/octave/3.6.4/";
    for Library_Name use "octave";
    for Library_Kind use "dynamic";
end Octave_Library;

I don't know why the Octave folks divide things up like this ("built-in" and "loadable") but I'm sure there's a good reason. I also dont't know what the structure of .oct files is but nm seemed to not choke so maybe they are like other library files. In any event, I have tried the following library description (in its own file):

library project Octave_oct_Library is
    for Externally_Built use "true";
    for Library_Dir use "/opt/local/lib/octave/3.6.4/oct/x86_64-apple-darwin13.3.0";
    for Library_Name use "besselj";
    for Library_Kind use "dynamic";
end Octave_oct_Library;

My main gpr file contains these two lines:

with "Octave_Library"; -- Octave built-in functions (not the loadable functions from Octave)
with "Octave_oct_Library"; -- Octave loadable functions. First try with Bessel functions only.

When I build this complaint results:

ld: library not found for -lbesselj

Note the "l" in front of besselj

I tried making a symlink to the besselj.oct file and tried to trick the linker by changing its name in a few ways with no success. However, when I named the symlink libbesselj.dylib I got this result:

ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file '/opt/local/lib/octave/3.6.4/oct/x86_64-apple-darwin13.3.0//libbesselj.dylib' for architecture x86_64

which seems to indicate that the .oct file is something called a MH_BUNDLE. (And why the "//" in the error message?) I found this discussion about MH_BUNDLE

http://stackoverflow.com/questions/2339679/what-are-the-differences-between-so-and-dylib-on-osx

which prompted me to do this:

$ otool -hv besselj.oct
besselj.oct:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00      BUNDLE    21       2128   NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK

At this point I'm in way over my head.

I use Ada nearly daily for general technical computing and supplement with Octave, Mathematica, and Igor Pro. Having a full binding to the Octave libraries (as well as GSL for example) would vastly help me and other Ada users but for now I'm just adding single-function bindings as I need them.

Thanks for any help.

Jerry


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-30  3:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-19 21:31 Help linking to Octave (mathematical) functions Jerry
2014-12-26 11:54 ` Blady
2014-12-28  3:38   ` Jerry
2014-12-29  9:21     ` Stephen Leake
2014-12-30  3:24       ` Jerry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox