loadlibrary - Matlab R2013b 64bit
4 views (last 30 days)
Show older comments
Guilherme
on 1 Dec 2014
Commented: Philip Borghesani
on 2 Dec 2014
Hello,
I have been trying to load a 64-bit library (.dll) using the command "loadlibrary" on Matlab 64-bit, but I always receive the following error:
Error using loadlibrary (line 418) C:\Users\****\AppData\Local\Temp\tpe7fb8e10_222c_47c3_ad59_ab00161c9411\shrlibsample_thunk_pcwin64.dll is not a valid Win32 application.
As you may see, the library I am attempting to load is the shrlibsample, using the following commands:
>> addpath(fullfile(matlabroot,'extern','examples','shrlib')) >> loadlibrary('shrlibsample','shrlibsample.h')
And I also have Microsoft Software Development Kit (SDK) 7.1 set as compiler for Matlab (mbuild -setup).
I have already read several questions related to this issue, but I did not find any similar to the problem I am facing: I am trying to load a 64-bit library on a 64-bit Matlab and the error reported by the latter is related to an expectation of loading a 32-bit library, what does not make sense to me.
Some additional info: I also have Matlab 32-bit installed on my computer (Win7 64-bit), which also makes use of SDK 7.1 as compiler and I am able to load any (32-bit) library on that Matlab.
Any ideas or suggestions are very much appreciated.
Thanks, Guilherme
0 Comments
Accepted Answer
Philip Borghesani
on 1 Dec 2014
Edited: Philip Borghesani
on 1 Dec 2014
Contacting support may be your best option for this problem. Something is most likely not configured or installed correctly with your compiler.
All 64bit and 32bit windows programs & dlls are considered to be win32 applications this is a Microsoft oddity (system32 contains all 64bit programs...). The error message does not necessarily indicate improper program type or confusion, just that it could not be loaded.
I would start by adding mfilename option to your loadlibrary command and then running Dependency Walker on the generated thunk dll to see if you can figure out what is wrong with it.
Does the mex command work correctly for you? Can you build and run an example mex file? What version of Matlab are you running the way loadlibrary builds the thunk files has changed in recent versions.
2 Comments
Philip Borghesani
on 2 Dec 2014
I should have noticed you also have 32bit MATLAB installed. One of the problems with this configuration is that mex -setup saves the setup to a file that is used by both 32 and 64 bit MATLAB but will only work correctly with the MATLAB it is created with.
More Answers (0)
See Also
Categories
Find more on Troubleshooting in MATLAB Compiler SDK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!