Why are the functions from the dll loaded into MATLAB using LOADLIBRARY unavailable?
6 views (last 30 days)
Show older comments
I am attempting to use LOADLIBRARY from the MATLAB Interface to Shared Libraries (i.e. GenericDLLs) to access a .dll file in MATLAB. It appears that I have successfully loaded the library into MATLAB, except for some warning messages.
The code below demonstrates the loading of my Windows dll:
loadlibrary('FOO.dll','C:/MyD/Libraries/FOO_Prototypes.h','includepath','C:/MyD/Libraries/')
After loading the dll into MATLAB, I receive the following warning messages:
Warning: The data type 'error' used by function VPX_InsertMessageRequest does not exist
(Type "warning off MATLAB:loadlibrary:typenotfound" to suppress this warning.)
Warning: The data type 'error' used by function VPX_InsertMessageRequest does not exist
(Type "warning off MATLAB:loadlibrary:typenotfound" to suppress this warning.)...
I verified that the dll is loaded into MATLAB by using the LIBISLOADED function:
libisloaded('FOO')
However, when I attempt to view the functions in the DLL with LIBMETHODSVIEW, I receive an error:
libmethodsview('FOO')
??? Error using ==> libmethodsview
No class lib.FOO can be located or no methods for class lib.FOO
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The problem of the dll functions not being available within MATLAB can be attributed to a number of things:
1. The improper use of
__declspec(dllexport)
This should be
__declspec(dllimport)
Or, you can avoid using the keyword entirely.
2. There is a bug in the LOADLIBRARY tool that causes a failure when multiple variables are declared on a line in a struct definition.
3. Avoid using variables or typedef names that begin with native C data types.
0 Comments
More Answers (0)
See Also
Categories
Find more on Call C from MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!