MATLAB Answers

Error at calling *.dll file in Matlab

49 views (last 30 days)
Jong-Hwan Kim
Jong-Hwan Kim on 6 May 2012
Answered: Ray on 10 Dec 2015
Hi,
I want to use icp.dll file in Matlab for a project. When I use my friend's laptop, which is 32 bit win7, Matlab 2009a. Matlab automatically recognize icp.dll and works fine. But, when I use my computer, 64 bit win7 Matlab 2011a, Matlab shows an error below.
=== error =====
loadlibrary('icp.dll','icp.h')
??? Error using ==> loadlibrary at 441
Failed to preprocess the input file.
Output from preprocessor is:icp.h
C:\matlab\test\icp.h(329) : error C2006:
'#include' : expected a filename, found 'identifier'
C:\matlab\test\icp.h(329) : fatal error
C1083: Cannot open include file: '': No such file or directory
=== error =====
Actually I don't have icp.h file, I only have icp.dll file. I really want to compile icp.dll file in MATLAB.
I hope you guys have an answer.
Thank you
[Merged information from duplicate question]
Hi,
I have icp.dll file, which works fine in 32bit win7 and Matlab 2009b, while it shows an error in 64bit Matlab 2011a.
===error====
??? Undefined function or method 'icp' for input arguments of type 'double'.
Error in ==> practice_ICP_NDT_01 at 87
delta = icp(p1, p2icp, delta, GATE1, NIT, INTERP)
===error====
Matlab seems not to recognize the icp.dll file so I commanded that
>> loadlibrary('icp.dll')
??? Error using ==> loadlibrary>lFullPath at 613
Could not find file icp.h.
Error in ==> loadlibrary at 226
header=lFullPath(header);
>> calllib('icp.dll')
??? Error using ==> calllib
To call a function both the library name and function name are needed.
I don't know how I can solve this problem and use icp.dll in Matlab Thanks.

  2 Comments

Kaustubha Govind
Kaustubha Govind on 7 May 2012
The LOADLIBRARY command needs either a header or generated prototype file (.m) corresponding to the DLL. If you don't have icp.h, how did you load it on your friend's machine?
Also, note that you will need 32-bit MATLAB to load a 32-bit DLL.
Walter Roberson
Walter Roberson on 7 May 2012
Your duplicate question has been merged into the above. You may wish to review it and edit out any redundant information.

Sign in to comment.

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 7 May 2012
Ah! It looks like you are using a MEX-function which used to have a .dll extension in very old releases of MATLAB. They now have extensions like mexw32, mexw64, etc. You can call these files directly like any other MATLAB function - there is no need to use LOADLIBRARY.
In any case, the issue is that MEX-files are platform-specific - the one you have is compiled for 32-bit Windows, so it won't be recognized on 64-bit MATLAB. If you have the source code corresponding to the file, you can use the MEX command to re-compile it for 64-bit Windows. Alternately, you can install 32-bit MATLAB on your 64-bit machines to run the 32-bit MEX-file. See How can I install 32-bit MATLAB on my 64-bit Windows machine?

  4 Comments

Show 1 older comment
Walter Roberson
Walter Roberson on 7 May 2012
A caution, though: mex functions old enough to have been compiled into .dll instead of .mexw32, were often not coded in the manner that would later be needed for 64 bit compatibility. Getting the source to work on 64 bit MATLAB would usually require going through and changing type names in the mex source.
Jong-Hwan Kim
Jong-Hwan Kim on 7 May 2012
I see, thank you for additional advise. I appreciate that :)
Jong-Hwan Kim
Jong-Hwan Kim on 8 May 2012
Finally, it worked well. Thank you very much

Sign in to comment.

More Answers (3)

Ray
Ray on 10 Dec 2015
I am wondering how do you fix this problem, by installing a 32 bit Matlab or other methods. Because I only have the .dll file without the .h file, and in the similar situation like yours.
Look forward to your reply

  0 Comments

Sign in to comment.


Walter Roberson
Walter Roberson on 6 May 2012
Windows does not know the character "~" as a directory name: that character is used by the Unix (Linux, OS-X) shells to mean "the user's home directory". You need to track down where that "~" is coming from: did you
cd ~
for example? Or is there an icp.h file that has a #include statement that uses it?

  1 Comment

Jong-Hwan Kim
Jong-Hwan Kim on 6 May 2012
I am sorry that I used '~' instead of 'matlab\test'. I fixed it.
icp.dll file locates at 'c:\matlab\test\' Thanks.

Sign in to comment.


Walter Roberson
Walter Roberson on 7 May 2012
Is icp.dll a product of the company Softlog ? If so then the software was strictly 32 bit and cannot be used from the 64 bit version of MATLAB.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by