Why am I unable to access functions in my generic library using MATLAB 7.0 (R14)?

2 views (last 30 days)
When I attempt to load a library using the LOADLIBRARY command, I receive the following warning:
Warning: The function 'PBD03PC_Init' was not found in the library
> In loadlibrary at 240
I am then unable to access any of the functions in my library. My library file contains the proper function names and the LIB-file associated with my DLL shows the functions as being exported.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 Feb 2010
This information has been added in the documentation for MATLAB 7.2 (R2006a). If you are using a previous version, read the following:
This behavior may occur if you compiled a C++ shared library without ensuring its compatibility with C using the syntax
extern "C" {
<function>
}
To work around this issue, you should recompile your library to function. Alternatively, you may create a prototype MATLAB file containing the mangled function names using the following steps:
1. Load the library with the syntax
loadlibrary('libname.dll','libname.h','mfilename','mProto');
This will create an MATLAB file named "mProto" containing the library information.
2. Unload the library
unloadlibrary libname
3. Modify the contents of "mProto" to contain the mangled function names. For example, if the function was called "Init", it may be called "?Init@@YGHXZ". The mangled function names can be obtained either by examining the LIB-file associated with your DLL or using the Dependency Walker tool, which can be found at:
www.dependencywalker.com
4. Load the library using the newly modified prototype file
loadlibrary('libname.dll',@mProto);

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!