Question: Problem using define_external to call a C++ function that calls Intel MKL code

I'm trying to debug a problem with define_external, and I would love some help!

I have a Maple module that contains this line of Maple code:

EigValsVecsC := define_external('EigValsVecsC', LIB = cat(dll_home,"\\operators.dll"), 'm'::ARRAY(datatype=float[8]), 'n'::integer[4], 'eig_vals'::ARRAY(datatype=float[8]), 'eig_vecs'::ARRAY(datatype=float[8]), 'THREAD_SAFE');

Running the Maple code to create the module produces this error message:

"Error, (in ModuleLoad) external linking: error loading external library C:\Users\zander\maple\toolbox\EigLib\misc\operators.dll: The specified procedure could not be found."

I've discovered that there's a single line of C++ code (in the C++ function EigValsVecsC) that I can comment out to make the problem go away.  Here's the line of C++ code:

MKL_INT info = LAPACKE_dsyev(LAPACK_ROW_MAJOR, 'V', 'U', eig_vecs.rows(), eig_vecs.raw(), eig_vecs.rows(), eig_vals.raw());

To clarify:

  • C++ compilation succeeds for operators.dll (which contains the function EigValsVecsC), with this one line either commented or uncommented.
  • The C++ function EigValsVecsC works correctly when not called from Maple (i.e., called from Visual Studio or the command line), with this one line either commented or uncommented.  (Of course, it doesn't work fully correctly with this one line commented, since this one line is the whole point of the function.  But it runs successfully and does the correct massaging of inputs.)
  • When this one line of C++ code is commented, the Maple module builds successfully, and I can call EigValsVecsC in Maple and get results back showing that, in the C++ code, the inputs to the commented line are being set up properly.

The relevant include statement in the C++ code is:

#include "mkl_lapacke.h"

I don't have to comment out the include statement (though the compiler may well be ignoring it if it's never used, when the call to LAPACKE_dsyev is commented out).

I have no good theories about what the problem may be.  I've been trolling the Web for any helpful information, and I've come up with nothing.

Can anyone help?  Thanks!

Please Wait...