Error calling MATLAB engine in external library (error 6400)
Hello all,
I have a .dll library linked to a DRESP3 card in Optistruct. It works fine, except if I call the MATLAB engine. The relevant code is the following, related to the MATLAB engine API:
Engine *ep; if(!(ep = engOpen(NULL))) { } engClose(ep);
If I comment out the lines containing engOpen and engClose, the .dll works fine. If I uncomment them, Optistruct generates the following error:
*** ERROR # 6400 *** The following (Path Removed).dll external library could not be loaded: (null) Please verify that the library path, name and extension are correct. Also check that the library was compiled and linked with appropriate. flags on the appropriate platform. See OptiStruct's user guide for. more information about building and using external libraries.
I'm at a loss to what causes the error. If I comment out the mentioned lines, the .dll works (i.e. generates .txt files as output), so I don't think it's a compilation or linking issue. The only thing I could think of is that the MATLAB functions are mixed caps/non-caps. If this is indeed the issue, are there any suggestions for workarounds?
Kind regards,
Matthijs
Answers
-
I am looking into this issue and I will get back to you soon.
But I think the error is coming from the library path. Engopen should lead to library path or can you try without NULL?
0 -
Hello Prakash,
The NULL in engOpen(NULL) refers to the command string with which MATLAB is opened. On Windows, it can only be NULL. MATLAB's engine library is linked to during compilation, as per the documentation of MATLAB's engine API, so I don't think it's the path to the library that's the issue.
Kind regards,
Matthijs
0 -
Hi,
I will check and update you soon on this.
0 -
Hi,
OS probably couldn’t recognize .dll built with matlab functions. We support external libraries which are written in Fortran or C, Excel, or HyperMath. Can you try withHhyperMath?
0 -
Hello Prakash,
The .dll doesn't contain any MATLAB functions; it only calls the MATLAB Engine API for C which (I presume) is written in C. Even then, if I include the statement:
Engine *ep
which uses a type definition from the Engine API (engine.h), there is no error. Besides, If I include the five lines of code from my first post in my main.c rather than in the entry point function that Optistruct calls, there is no error. From that, I don't think there is an error in the compilation of the code.
I have tried with Hypermath, but it doesn't offer a number of predefined functions I can use in MATLAB (I could program them myself, but I have only limited time and coding experience, so I'd rather not).
0 -
0