Error with using loadlibrary() with .lib file

5 ビュー (過去 30 日間)
Mark Kelly
Mark Kelly 2024 年 3 月 1 日
回答済み: Gyan Vaibhav 2024 年 3 月 7 日
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 Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by