Error calling loadlibrary: "functions not found"

5 visualizaciones (últimos 30 días)
Siqi Li
Siqi Li el 30 de Mzo. de 2015
Comentada: snow John el 30 de Sept. de 2021
I'm trying to automate a device using Matlab through calling a dll file provided by the manufacturer. However, it kept returning errors saying "functions not found", even after I checked with "libisloaded" and Matlab returns 1. Here is the code and error messages:
>> fullpathToDll='C:\D4100_DLLHeaders\D4100_usb.dll'
fullpathToDll =
C:\D4100_DLLHeaders\D4100_usb.dll
>> header1='C:\D4100_DLLHeaders\D4100_usb';
>> header2='C:\D4100_DLLHeaders\resource.h';
>> header3='C:\D4100_DLLHeaders\devioctl.h';
>> header4='C:\D4100_DLLHeaders\ezusbsys.h';
>> header5='C:\D4100_DLLHeaders\main.h';
>> header6='C:\D4100_DLLHeaders\RegisterDefines.h';
[notfound,warnings]=loadlibrary(fullpathToDll,header1,'addheader',header2,'addheader',header3,'addheader',header4,'addheader',header5,'addheader',header6);
Warning: Message from C preprocessor:
lcc preprocessor warning: C:\D4100_DLLHeaders\main.h:173 C:\D4100_DLLHeaders\D4100_usb.h:19 EOF inside comment
lcc preprocessor warning: C:\D4100_DLLHeaders\RegisterDefines.h:40 C:\D4100_DLLHeaders\D4100_usb.h:23 EOF inside comment
lcc preprocessor warning: C:\D4100_DLLHeaders\D4100_usb.h:69 EOF inside comment
> In loadlibrary at 266
Warning: Warnings messages were produced while parsing. Check the functions you
intend to use for correctness. Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary at 275
Warning: The function 'bOpenDriver' was not found in the library
> In loadlibrary at 319
Warning: The function 'ParseDeviceDescriptor' was not found in the library
> In loadlibrary at 319
Warning: The function 'ParseConfigurationDescriptor' was not found in the library
> In loadlibrary at 319
Warning: The function 'DumpBuffer' was not found in the library
> In loadlibrary at 319
Warning: No functions found in library.
> In loadlibrary at 327
The functions that give the warnings are from 'main.h'. What's causing the problems? Is there something wrong with the header files? I got those from the manufacturer and they have verified that the files work on LabView but have not tested them in Matlab.
Could someone help me solve this problem? Thanks!!
Siqi

Respuestas (2)

Siqi Li
Siqi Li el 7 de Abr. de 2015
With a second look, I suspect that this might be a compiler issue. Matlab is using lcc compiler, which is C. But in my header file, it contains "extern "C" ", which means it's for C++? Here is what my main header file looks like:
#define DLL_EXPORT
#if defined DLL_EXPORT
#define USB_DLL __declspec(dllexport)
#else
#define USB_DLL __declspec(dllimport)
#endif
#undef UNICODE
#include <windows.h>
#include <malloc.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "stdarg.h"
#include "main.h"
#include "devioctl.h"
#include "ezusbsys.h"
#include "RegisterDefines.h"
extern "C"
{ ...//a bunch of functions here
}
//#############EOF##################
I also created a prototype file, using the demo from the previous answer. I ran it using loadlibrary(dllfilename,@mfilename). With "libisloaded", it returns 1, but the problem is "no functions found".
Is it really the compiler causing this issue? How should I change it?
Thanks!!
Siqi
  1 comentario
snow John
snow John el 30 de Sept. de 2021
Hello,I get the same problem.
Did finaly you fix it ?

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 30 de Mzo. de 2015
Did you run Dependency Walker (Google it) on your DLL to see what functions it actually has in it?
  5 comentarios
Siqi Li
Siqi Li el 7 de Abr. de 2015
Hello,
With a second look, I suspect that this might be a compiler issue. Matlab is using lcc compiler, which is C. But in my header file, it contains "extern "C" ", which means it's for C++? Here is what my main header file looks like:
#define DLL_EXPORT #if defined DLL_EXPORT #define USB_DLL __declspec(dllexport) #else #define USB_DLL __declspec(dllimport) #endif #undef UNICODE #include windows.h #include malloc.h #include assert.h #include stdlib.h #include stdio.h #include "stdarg.h" #include "main.h" #include "devioctl.h" #include "ezusbsys.h" #include "RegisterDefines.h" extern "C" { ...//a bunch of functions here } //#############EOF################## I also created a prototype file, using the demo from the previous answer. I ran it using loadlibrary(dllfilename,@mfilename). With "libisloaded", it returns 1, but the problem is "no functions found".
Is it really the compiler causing this issue? How should I change it?
Thanks!!
Siqi
Image Analyst
Image Analyst el 7 de Abr. de 2015
I don't really know - I've only had to do it once. I think you should just call them and ask them. Might as well get some support from them considering the huge amount of money you had to pay for the compiler toolbox.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB Compiler en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by