Jump to content
Sign in to follow this  
Matthijsdejong

Error calling MATLAB engine in external library (error 6400)

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest

Hi @Matthijsdejong

 

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Guest

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?

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...