From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!news.roellig-ltd.de!open-news-network.org!news.alphanet.ch!alphanet.ch!.POSTED!not-for-mail From: Blady Newsgroups: comp.lang.ada Subject: Re: Help linking to Octave (mathematical) functions Date: Fri, 26 Dec 2014 12:54:53 +0100 Organization: Posted through ALPHANET (http://www.alphanet.ch/) Sender: blady@anantes-656-1-73-204.w90-49.abo.wanadoo.fr Message-ID: References: <74a567c4-eb60-4bc1-b03a-4c3a7be7676f@googlegroups.com> NNTP-Posting-Host: anantes-656-1-73-204.w90-49.abo.wanadoo.fr Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: shakotay.alphanet.ch 1419594893 16467 90.49.128.204 (26 Dec 2014 11:54:53 GMT) X-Complaints-To: usenet@alphanet.ch NNTP-Posting-Date: Fri, 26 Dec 2014 11:54:53 +0000 (UTC) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <74a567c4-eb60-4bc1-b03a-4c3a7be7676f@googlegroups.com> Xref: news.eternal-september.org comp.lang.ada:24234 Date: 2014-12-26T12:54:53+01:00 List-Id: 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 >