C Dll does not find all header paths

4 次查看(过去 30 天)

Hello all,

I am currently trying to call functions from a dll from within MATLAB. Here are two things that I tried and have questions about:

1.:

calllib("C:\Windows\System32\mxsvcb.dll",'mxCardsReset',0)

This is the way I am used to calling Dlls (from LabVIEW): reference the dll, select a function and pass the parameters. However, when I call this, I get an error back: Error using calllib Library was not found

The file is definitely at that location. Is this sort of call possible?

2.: When I go to the documentation folder and call

loadlibrary('C:\Windows\System32\mxsvcb.dll','\apimx\apimx.h')

I get a different error, that tells me the file that is being referenced by an include does not exist "common/nowarn.h". Now, that file is in a parallel folder and not in a subfolder to the "apimx.h", so the path would be "../../common/nowarn.h" from where apimx is.

Because of this, I copied the folder into the "apimx" folder and got the same message for the next include in line. Since the header files reference each other, I can't rearrange everything, because it would take a long time. Is there a way to make MATLAB understand the structure better?

Edit: Sorry, somehow the post got submitted while adding tags.

  3 个评论
Dennis
Dennis 2018-10-2
Which version of matlab are you using and are your .dll 32 or 64 bit?
Peter Foerster
Peter Foerster 2018-10-3
It's a 32 Bit dll on MATLAB R2018b 64-Bit, but for now, I don't believe that to be the issue, since the error message clearly indicate some issues with referencing the header files. (I'd expect to be able to call 32 bit dlls from 64 bit MATLAB anyway)

请先登录,再进行评论。

采纳的回答

Guillaume
Guillaume 2018-10-2
编辑:Guillaume 2018-10-2
You cannot use calllib in matlab unless you have first loaded the library with loadlibrary.
If there is a bunch of include file that are not found because they're in a different folder then you need to tell loadlibrary where to find them, using the includepath option (Not that this is orthogonal to addpath which is for m files). From your description, it looks like includepath should point to whatever ../.. is, so
loadlibrary('C:\Windows\System32\mxsvcb.dll','\apimx\apimx.h', 'includepath', '\apimx\..\..\')
may work.
  1 个评论
Peter Foerster
Peter Foerster 2018-10-3
Hi Guillaume,
thanks for your answer! Just to clarify a few things: when I write .. I mean out one folder. Also, if the option is inlcudepath and not addpath, why are they using addpath in the loadlibrary example?
I have tried your suggestion, but it still gives me the same error as without the 'includepath'. It is telling me no such file or directory #include common/nowarn.h, regardless of how I put in the path:
loadlibrary('C:\Windows\System32\mxsvcb.dll','\apimx\apimx.h','includepath', 'c:\Program Files\MAX Technologies\maxapi\common\')
loadlibrary('C:\Windows\System32\mxsvcb.dll','\apimx\apimx.h','includepath', '\common\')
loadlibrary('C:\Windows\System32\mxsvcb.dll','\apimx\apimx.h','includepath', '\..\common\')
It doesn't appear to be searching the includepath at all, because the actual call for common/nowarn.h comes from another header file that is referenced in apimx.h. Is there any way to do this without header file?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by