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 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.214.72 with SMTP id ny8mr8195198obc.18.1419024700781; Fri, 19 Dec 2014 13:31:40 -0800 (PST) X-Received: by 10.50.132.71 with SMTP id os7mr86795igb.11.1419024700691; Fri, 19 Dec 2014 13:31:40 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!h15no14511930igd.0!news-out.google.com!d20ni20372igz.0!nntp.google.com!h15no26371677igd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 19 Dec 2014 13:31:40 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=97.117.194.10; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG NNTP-Posting-Host: 97.117.194.10 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <74a567c4-eb60-4bc1-b03a-4c3a7be7676f@googlegroups.com> Subject: Help linking to Octave (mathematical) functions From: Jerry Injection-Date: Fri, 19 Dec 2014 21:31:40 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 4357 X-Received-Body-CRC: 2849920053 Xref: news.eternal-september.org comp.lang.ada:24163 Date: 2014-12-19T13:31:40-08:00 List-Id: Sorry for the long post. I use GNAT on OS X 10.9.4. I'm trying to bind to a "loadable function" in O= ctave, 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 stor= ed 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=20 /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" an= d "loadable") but I'm sure there's a good reason. I also dont't know what t= he 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-darwi= n13.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 funct= ions from Octave) with "Octave_oct_Library"; -- Octave loadable functions. First try with Bes= sel 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 lin= ker by changing its name in a few ways with no success. However, when I nam= ed the symlink libbesselj.dylib I got this result: ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file '/opt/lo= cal/lib/octave/3.6.4/oct/x86_64-apple-darwin13.3.0//libbesselj.dylib' for a= rchitecture 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 flag= s MH_MAGIC_64 X86_64 ALL 0x00 BUNDLE 21 2128 NOUNDEF= S 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 libr= aries (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