comp.lang.ada
 help / color / mirror / Atom feed
From: Blady <p.p11@orange.fr>
Subject: Re: Help linking to Octave (mathematical) functions
Date: Fri, 26 Dec 2014 12:54:53 +0100
Date: 2014-12-26T12:54:53+01:00	[thread overview]
Message-ID: <m7jiad$g2j$1@shakotay.alphanet.ch> (raw)
In-Reply-To: <74a567c4-eb60-4bc1-b03a-4c3a7be7676f@googlegroups.com>

Hello Jerry,

Despite the documentation said it is like "shared library or shared 
object", it is referring to Octave itself "An oct-file is a dynamical 
extension of the Octave interpreter".
On MacOS, even with GNAT, at the end, all object files are loaded by ld 
but I haven't seen that oct files are supported by ld.

In the documentation it is specified at §1.1.3.5. Running: "If the 
oct-file is in the LOADPATH, it will be loaded automatically – either 
when requesting help on the function or when invoking it directly."

Have you set LOADPATH to your bessel library?

HTH, Pascal.

Le 19/12/2014 22:31, Jerry a écrit :
> 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
>

  reply	other threads:[~2014-12-26 11:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-19 21:31 Help linking to Octave (mathematical) functions Jerry
2014-12-26 11:54 ` Blady [this message]
2014-12-28  3:38   ` Jerry
2014-12-29  9:21     ` Stephen Leake
2014-12-30  3:24       ` Jerry
replies disabled

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