From: Mark Patterson on
Hi,

I'm trying to access a DLL from MATLAB but I receive the errors:
Warning: The function 'maintDLL' was not found in the library.
Warning: No functions found in library.
(maintDLL is the only function in the DLL).

The MATLAB syntax I'm using to load the library is:
[notfound warnings] = loadlibrary('libmaintDLL.dll',
'maintDLL.h', 'alias', 'libmaint')

The function prototype in maintDLL.h is:
extern __declspec(dllimport) __stdcall int maintDLL(
DWORD dllCallFunction,
dllCommsPtr_t dllComms,
dllMsgPtr_t dllMsg,
dlldbdPtr_t dllMsgOut,
int *numRecords);
I have omitted the various type definitions for the arguments here, but
they are all defined in the header file. When I generate the prototype
m-file with the 'mfilename' argument to loadlibrary(), the data types
appear to have been correctly parsed. Using a simplified prototype
without the custom data types but the same memory footprint for the
arguments (or even an incorrect memory footprint) does not alter the
error.

Using Dependency Walker (http://www.dependencywalker.com/), I have
verified that the DLL does in fact contain the maintDLL() function.

I have read through all the forum posts related to loadlibrary and I
have not been able to find a solution.

Does anyone know what would cause MATLAB to be unable to find a function
in a DLL?

Thank you,
Mark Patterson
From: us on
"Mark Patterson" <cleobis(a)gmail.com> wrote in message <i0j5ph$oo2$1(a)fred.mathworks.com>...
> Hi,
>
> I'm trying to access a DLL from MATLAB but I receive the errors:
> Warning: The function 'maintDLL' was not found in the library.
> Warning: No functions found in library.
> (maintDLL is the only function in the DLL).
>
> The MATLAB syntax I'm using to load the library is:
> [notfound warnings] = loadlibrary('libmaintDLL.dll',
> 'maintDLL.h', 'alias', 'libmaint')

just a wild guess:
- is it possible that you use the wrong extension [.dll]...
- is it possible that you use a different OS/ML version...

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/loadlibrary.html#f103-540877

which OS/ML version/compiler do you use...

us
From: Mark Patterson on
"us " <us(a)neurol.unizh.ch> wrote in message <i0j6v1$9er$1(a)fred.mathworks.com>...
> "Mark Patterson" <cleobis(a)gmail.com> wrote in message <i0j5ph$oo2$1(a)fred.mathworks.com>...
> > Hi,
> >
> > I'm trying to access a DLL from MATLAB but I receive the errors:
> > Warning: The function 'maintDLL' was not found in the library.
> > Warning: No functions found in library.
> > (maintDLL is the only function in the DLL).
> >
> > The MATLAB syntax I'm using to load the library is:
> > [notfound warnings] = loadlibrary('libmaintDLL.dll',
> > 'maintDLL.h', 'alias', 'libmaint')
>
> just a wild guess:
> - is it possible that you use the wrong extension [.dll]...
> - is it possible that you use a different OS/ML version...
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/loadlibrary.html#f103-540877
>
> which OS/ML version/compiler do you use...
>
> us

I believe the the file extension (.dll) is correct. MATLAB is certainly finding the file as I get a different error if I put in the wrong file name.

I'm using Windows XP and MATLAB 2009b. The DLL was compiled from C code by the provider. I don't know which compiler they used.

Thank you,
Mark Patterson
From: us on
"Mark Patterson"
> I believe the the file extension (.dll) is correct. MATLAB is certainly finding the file as I get a different error if I put in the wrong file name.
>
> I'm using Windows XP and MATLAB 2009b. The DLL was compiled from C code by the provider. I don't know which compiler they used.
>
> Thank you,
> Mark Patterson

well... there seems to be your black-box: the compiler...
- can you get the information, eg, bitsize,...
- furthermore, is your function visible, eg, what does LIBFUNCTIONS

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/libfunctions.html

yield(?)...

just a few more thoughts
us
From: Mark Patterson on
"us " <us(a)neurol.unizh.ch> wrote in message <i0j9n8$t5n$1(a)fred.mathworks.com>...
> well... there seems to be your black-box: the compiler...
> - can you get the information, eg, bitsize,...
> - furthermore, is your function visible, eg, what does LIBFUNCTIONS
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/libfunctions.html
>
> yield(?)...
>
> just a few more thoughts
> us

libfunctions() indicates that there are no functions in the library, consistent with the failure of loadlibrary, but contrary to the desired behaviour. As libfunctions requires the library to be already loaded, I would not expect it to list the function until loadlibrary executes without issues.

I agree that the compiler is a big question. Unfortunately, the DLL was prepared by someone else, I'm trying to understand what could be wrong with either what I'm doing in MATLAB or how the library was prepared. This library has been used successfully with other applications.

Thank you,
Mark Patterson