Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.maple > #910
| Newsgroups | comp.soft-sys.math.maple |
|---|---|
| Date | 2014-06-23 07:45 -0700 |
| References | <9ZednZnd5Ma6WjrOnZ2dnUVZ_o-dnZ2d@megapath.net> |
| Message-ID | <6b2b1df0-e721-46d1-841d-0d9a9de06c52@googlegroups.com> (permalink) |
| Subject | Re: Define External and libname |
| From | acer <maple@rogers.com> |
On Monday, June 23, 2014 2:20:22 AM UTC-4, Thomas D. Dean wrote:
> Maple 15.
>
>
>
> I used define_external(...) to do interactions with gnuplot. I want to
>
> use this to interface with some other 'C' functions. I seem to remember
>
> that libname was used by maple in loading the external library.
>
>
>
> My test case,
>
>
>
> > cat mymult.c
>
> int mult( int a, int b )
>
> {
>
> return a * b;
>
> }
>
>
>
> > gcc -fPIC -shared mymult.c -o mymult.so
>
>
>
> > cat testmult.mpl
>
> restart;
>
> mymult:=define_external('mult',
>
> LIB="mymult.so",
>
> 'a'::integer[4],
>
> 'b'::integer[4],
>
> RETURN::integer[4]
>
> );
>
> mymult(15,16);
>
>
>
> does not work unless I put the full path name on the LIB name.
>
>
>
> mymult.so is in
>
>
>
> /home/tomdean/Math/Maple/lib
>
>
>
> and maple's libname contains
>
>
>
> > libname;
>
> "/usr/local/maple15/lib",
>
> "/home/tomdean/maple/toolbox/Syrup/lib",
>
> "/home/tomdean/Math/Maple/lib",
>
> "/home/tomdean/maple/toolbox/Syrup/lib"
>
>
>
> If I use
>
>
>
> LIB="/home/tomdean/Math/Maple/lib/mymult.so",
>
>
>
> it works.
>
>
>
> Is there some definition that define_external uses to locate libs?
>
>
>
> Tom Dean
`define_external` does not use the value in Maple of `libname` to find such additonal shared libraries. It uses LD_LIBRARY_PATH from the OS shell.
Your example with LIB="/home/tomdean/Math/Maple/lib/mymult.so" only works because that is the fully qualified location, not because you have "/home/tomdean/Math/Maple/lib" as an entry in `libname`.
I'm guessing that you want to know a location that Maple will pick up automatically, without having to dirty your Maple installations primary bin.xxxx binary directory with files of your own. That's wise.
One way to proceed is to make Maple think that you have a personal installation of a Maple toolbox named, say, misc, and then place your mymult.so in its associated binary subdrectory.
Create a subdirectory,
"/home/tomdean/maple/toolbox/misc"
and then within that a subdirectory,
"/home/tomdean/maple/toolbox/misc/bin.xxxx"
where "bin.xxxx" is actually either "bin.IBM_INTEL_LINUX" or "bin.X86_64_LINUX" according to whether you are using 32bit or 64bit Maple.
The Maple command `kernelopts(system);` will show you which, and you just need to fill in the underscores.
The way this all works is very simple. When Maple launches it simply adds such detected "~/maple/toolbox/yyyy/bin.xxxx" directories to the LD_LIBRARY_PATH of its own shell. You can see all this by issuing the Maple command `getenv(LD_LIBRARY_PATH);`.
You can also use,
"/home/tomdean/maple/toolbox/misc/lib"
to have Maple automatically add that location to `libname`. So you could save modules and procedures (perhaps related in functionality to your additional .so shared libraries) in .mla archives under that location. In essence, you are just building your own add-on toolbox.
You should also be able to use a location which is picked up only by specific versions. Eg,
"/home/tomdean/maple/toolbox/18/misc"
Let us know how it works out.
Back to comp.soft-sys.math.maple | Previous | Next — Previous in thread | Next in thread | Find similar
Define External and libname "Thomas D. Dean" <tomdean@speakeasy.org> - 2014-06-22 23:20 -0700
Re: Define External and libname acer <maple@rogers.com> - 2014-06-23 07:45 -0700
Re: Define External and libname "Thomas D. Dean" <tomdean@speakeasy.org> - 2014-06-23 13:10 -0700
Re: Define External and libname acer <maple@rogers.com> - 2014-06-23 15:58 -0700
Re: Define External and libname "Thomas D. Dean" <tomdean@speakeasy.org> - 2014-06-23 16:20 -0700
csiph-web