Items tagged with external


I'm trying to call a C function which returns an array. The example on the help page is to pass in an array with known dimensions, which will be updated in the C function, but I wonder if this is the only way to do it. For example if I have an array of unknown dimensions beforehand, what is the best approach to return this array?


How can I call to an external batch file (which is located in a given directory) from a Maple session?


Janos Pinter


I've created compiled and executed Fortran 77 code, and then created a .dll file - using g77, for calling as external function in MAPLE 18. I have received the following : Error loading external library. Details are below. Can anyone explain what is going wrong?

Below is the history the steps I have taken:

Here is the contenct of my FORTAN source code file: test2.for 

REAL x,y, mult
x = 4.0
y = 3.0
OUT = mult(y,x)
11 FORMAT(1X,3E12.4)

function mult( a, b )
REAL a,b, mult
mult = a*b

The compile, execute and shared library creation steps are as follows  (using g77):

g77 -v -Wall -c -malign-double test2.for
g77 -v "test2.for" -o "test2" 
..execution ran successfully. Creation of dll:

g77 -s -o "test2.dll" "test2.for"

...this executed successfully

Defining as external function in MAPLE:
fmult := define_external('mult', LIB = "S:/MRBwork/IT/Fortran/projects/MAPLE - Fortran/CERN primes/test2.dll", FORTRAN, 'a'::(float[4]), 'b'::(float[4]), RETURN::(float[4]))

... but received following error.

Error, external linking: error loading external library S:/MRBwork/IT/Fortran/projects/MAPLE - Fortran/CERN primes/test2.dll: @�b%

Can someone take and look at the above and explain what may be causing the erroo ion the loading the .dll file?



Due to the seemingly persistent tabbing-problem, I would like to learn how to work with Maple using an external editor: If I could recreate my packages using an external editor, thereby avoiding both the tabbing-issue and the blowup associated with what I call the 'XML-contamination of documents', and from them create the associated libraries, then I would be satisfied. For then I would use only a single document in Maple worksheet mode as a front end. Therefore:

Can anyone point me to some information concerning 1.) choice of an editor, and 2.) how to use an external editor to create packages and libraries in Maple?

Dear Maple Developers,

Maple offers OpenMaple, which is nice and sufficient for driving Maple from extermal applications.

On the other hand Maple offers only very limited support for calling Java methods from maple (static emthods only, no objects).

So it is only possible with programming some extra static Java adapter classes to work with Java objects and their methods. This is a very cimbersome and clumsy workaround only.

Compared to applications...


I'm trying to get a hold of using DLL with Maple at the moment.

Just to give you some background informations.

My Headerfile:


using namespade std;

namespace WAVEFUNC

I would like to know if it is possible in an external program (C or Python) to create a Maple function ( Not a one liner, maybe a number of lines of Maple code ). Then call Maple to execute a separate Maple function and get the result back.


I've got this annoying problem and it's quite simple reproducible.

> with(GraphTheory): G := Graph({{a, b}, {b, c}, {c, d}}); Edges(G);

Edges(G) returns me

Error, (in EdgesExt) external library could not be found/used


It's the first time I encounter such a problem and have no idea on how to solve it, any advice?

I can see that

Problem: Write the equation internal bisector and external bisector of a triangle ABC with A(1,2,-7), B(3,-1,-1), C(-5,14,-3). This is my code.

> with(LinearAlgebra):
> A:=: B:=: C:=: M:=:
>v:=1/Norm(A-B,2)*(A - B) + 1/Norm(A-C,2)*(A - C): M=A + v*t;
>u:= 1/Norm(A-B,2)*(A - B) - 1/Norm(A-C,2)*(A - C): M=A + u*t;
in the commands M = A + v*t and M = A + u*t, please comment for me. Thank you.

1) Compile under vc express 2010 debug config. Don't forget point out your location of maplec.lib in configuration properties/Linker/General/Additional library directories. Assure that configuration is at least Debug or all.

2) Run sheet from Debug directory.


Have permanent crash on BombardByRandoms call. If i would transmit creating of rtable from 'InitInternal'...

My Maple14 program occasionally needs to skip to Pari-GP to do some algebraic number theory calculations.

The code for WindowsXP is as follows (the code for Windows7 is a little different):

   readstat("In a Pari window enter \\r p When done enter ; at the end of this line.");

Thus I need to put Pari in the foreground, and when done, bring my Maple program back to the

foreground. My program has already set p in the Pari directory to the appropriate Pari script.

how can i call python code in maple like external call for C++/Java/C#...

i have a text parser written in python and want to use it

can someone help me?

External calling functions from Windows dlls in Maple uses __stdcall calling convention.

Most Windows dlls including <windows.h> are using that convention (called also WINAPI). However, C runtime dll (msvcrt.dll) and most mathematical dlls - such as gsl, PARI, etc. which would be very useful, are using __cdecl calling convention and functions from them can not be easily called from Maple. One has to create a wrapper dll with __stdcall calling convention for that. In particular, Axel Vogt did that for a part of PARI.

Would that be possible for Maplesoft developers to add option CDECL in define_external in Maple 15 allowing calling C library functions and functions from gsl, PARI, etc. directly from Maple, without a burden of writing __stdcall wrappers for them first?

A couple of days ago I found out that gzread from the zlib library can be used for fast reading of binary files in Maple from the disk to memory - about 100 times faster than readbytes - something like in the following simplified example, 






                                99, 99

local gzopen, gzread, gzclose, n, p, A;
try p:=gzopen(f,"rb");
if gzread(p,A,n)=n
then return A end if
finally gzclose(p)
end try
end proc:



                                99, 99


                  0.078, 0.062, 0.046, 0.046, 0.046



That needs some tweaking, because that works only on uncompressed files. If a file ("A" in this example) was gzipped, then the gzread would ungzip n (uncompressed) bytes in it in this example, instead of copying it into the memory - but it is not a big deal, in general.

Does anybody know about a similar replacement for writebytes? gzwrite doesn't work for copying (it compresses the array.)

I used the zlibwapi.dll library from, it is a version of zlib 1.2.5 (written by Jean-Loup Gailly and Mark Adler) built by Gilles Vollant. The code is for a 32-bit system (Windows). That should work in 32-bit Linux after replacing that dll with standard, as well as on 64-bit systems after replacing integer[4] with integer[8] in most places.


I'm trying to use a simple DLL in maple, which I create based on Maple external linking examples..

int __stdcall mult( int a, int b )
         return a * b;

and I compiled it with Visual Studio 2010 compiler, but when I use it in Maple I recieve the error

"Error, external linking: error loading external library"


1 2 Page 1 of 2