Load C/C++ shared library into MATLAB - '.dll is not a valid Win32 application'

12 views (last 30 days)
Thank you in advance.
I tried to load a C library (as enclosed) into matlab and got an error 'dll is not a valid Win32 application' as follows. May ask what is the issue and how can I resolve it ?
% load SDK
addpath(fullfile(matlabroot,'extern','ifmO3D'))
if not(libisloaded('pmdaccess2'))
loadlibrary('pmdaccess2','pmdsdk2common.h','addheader','pmddatadescription.h','addheader','pmdsdk2.h')
end
libfunctions('pmdaccess2')
.............Error ...........................
In loadlibrary
In ifm_O3D_Interface (line 8)
Error using loadlibrary
There was an error loading the library "C:\Program Files\MATLAB\R2016a\extern\ifmO3D\pmdaccess2.dll"
C:\Program Files\MATLAB\R2016a\extern\ifmO3D\pmdaccess2.dll is not a valid Win32 application.
Error in ifm_O3D_Interface (line 8)
loadlibrary('pmdaccess2','pmdsdk2common.h','addheader','pmddatadescription.h','addheader','pmdsdk2.h')
Caused by:
Error using loaddefinedlibrary
C:\Program Files\MATLAB\R2016a\extern\ifmO3D\pmdaccess2.dll is not a valid Win32 application.

Answers (1)

Pico Technology
Pico Technology on 12 Oct 2016
Hi Seungkook,
Is the dll that you are attempting to load a 64-bit version? If not this is likely to be the issue as MATLAB 2016a is only available as a 64-bit version.
You may also need to set up a 64-bit compiler and call
mex -setup

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!