Error with using loadlibrary() with .lib file

10 次查看(过去 30 天)
I'm trying to get MATLAB to load the library of an NI library file (.lib) named FlexMS32.lib. I downloaded the 32-bit MATLAB R2015b environment so it could interface with the file. However, when I try to load it, it returns this error:
Error using loaddefinedlibrary
...FlexMS32.lib is not a valid Win32 application.
I have no idea why it's returning this error. This is all the code I'm running:
loadlibrary('FlexMS32.lib', 'flexmotn.h', ...
'addheader', 'flexcomp.h', ...
'addheader', 'MotnCnst.h', ...
'addheader', 'MotnErr.h', ...
'addheader', 'nimcBasicTypes.h' ...
);

回答(1 个)

Gyan Vaibhav
Gyan Vaibhav 2024-3-7
Hi Mark,
If you could provide the lib file it would be easier for me to determine the error. However, looking at the error, I feel there are two possible reasons for this.
  1. Static libraries can't be loaded using loadlibrary. You have to convert it to a dll before using it. I've also read from another question's answer that one way to do this is to create a mex file that calls the function in the library.
  2. The error also suggests a possiblity that that a 64 bit operating system is trying to load a 32 bit Win32 file. Follow this answer to use the workaround. https://www.mathworks.com/matlabcentral/answers/99364-how-do-i-resolve-loadlibrary-failed-with-error-193-1-is-not-a-valid-win32-error-message-in-simul
Hope this helps.
Thanks
Gyan

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by