|
I am trying to write code in MATLAB to communicate with a piece of proprietary hardware. Along with the hardware, I was given a driver file and some source code to define the functions that control the hardware via the driver. This source code includes files of the following extensions: .h, .c, .dsp, .dsw, and .lib (created with MS Visual Studio)
I need to be able to include these function descriptions in my code. How do I go about doing so?
Thanks in advance,
Michael
|
|
|
|
|
Hi,
You must create the MATLAB MEX file. See my article about MEX files here:
- MATLAB MEX-files[^]
Best regards,
A. Riazi
|
|
|
|
|
Hi Riazi,
I've installed the MATLAB Compiler 7. Now the mcc command is working but there is no cpp directory in the x:\matlab\extern\include\cpp for "matlab.hpp" also there is no file "matlab.h" in x:\matlab\extern\include\. There are no lib files "libmatpm.lib, libmatlb.lib, libmmfile.lib" in "x:\matlab\extern\lib\win32\microsoft\msvc71\"
I use "mcc -t -L C -W lib:MeanFunctionLib -T link:lib MeanFunction.m" to create "MeanFunctionLib.dll, MeanFunctionLib.lib and MeanFunctionLib.h"
Its giving me the error of Linking with "mcInitializeApplication".
Please help me how to run the simple MeanFunction.m from VC++.
Thanks & Regards,
Ardhendu
|
|
|
|
|
I wrote this article and it's source code with MATLAB 6.5 (version 13). I didn't install MATLAB 7 and unfortunately don't know anything about it's files & directories structure.
Best regards,
A. Riazi
|
|
|
|
|
Hi Riazi,
I read your article "MATLAB Shared LIbrary" and it is very interesting to me. I wish to access my function from the VC++. I download your code, but in my MATLAB 6.5 there is no library "libmmfile.lib" in "C:\MATLAB6p5\extern\lib\win32\microsoft\msvc60". Also there is no "Matlab.h" in the directory C:\MATLAB6p5\extern\include\".
Could you please help me how to compile the project without this files?
Also in my previous mail. I asked about the "MCC" commands in the MATLAB command window. It is not recognize in my Matlab command window.
Could you please help me???
Thanks & Regards,
Ardhendu
|
|
|
|
|
I read your message, it seems that you didn't install the MATLAB C/C++ MATH library toolbox.
For compiling your m-files or using MATLAB shared library or ..., you must have this toolbox (you should purchase it )
Best regards,
A. Riazi
|
|
|
|
|
Thanks a lot. I've to look for that..
|
|
|
|
|
Hi,
I'm new to the matlab and I want to call my matlab function
Myfun.m from my C code (VC++). I checked for building the DLL for the VC++. The command is "mcc". This command is not recognize in my MATLAB 6.5 command window.
Can anybody help me about this??
Thanks in advance.
Regards,
Ardhendu
|
|
|
|
|
I read your message, it seems that you didn't install the MATLAB C/C++ MATH library toolbox.
For compiling your m-files or using MATLAB shared library or ..., you must have this toolbox (you should purchase it )
Best regards,
A. Riazi
|
|
|
|
|
Hi Riazi,
Is this tool box ( MATLAB C/C++ MATH library) come with MATLAB Compiler License?
Thanks & Regards,
-Ardhendu
|
|
|
|
|
|
I want to compile matlab image processing function such as imread, imshow to DLL, and then I want to use that DLL in my MFC project , Please help me .
|
|
|
|
|
Instead of doing this, just use CxImage[^]
A. Riazi
|
|
|
|
|
Hi Riazi!
I am trying to embed a Matlab DLL into a COM object.
Building process reports no errors, but during registration I get an error message:
....
....
Linking...
Performing registration
Project : error PRJ0019: A tool returned an error code from "Performing registration"
If I register the COM manualy from the console with Regsvr32 it doesn't report any error. If I try then to call the COM from some client programm I get a runtime error .
I am using "Microsoft Visual C++ .NET 2003".
Have You ever had such a problem ?
Thanks !
Best regards !
Nedo.
|
|
|
|
|
Mathworks issued that MATLAB 6 Compiler/COM builder is not compatible with MS Visual Studio.NET. But I'm not sure that, this is your problem.
A. Riazi
|
|
|
|
|
Hi Nedo,
I'm having the same problem. I think the reason you can run regsvr32 in the console and not in the IDE is because of your PATH. When you run in the console, your PATH probably has the "v70\runtime\win32" directory and so when you register your COM DLL, it is able to find the Matlab DLL that it needs to load. However, when you perform the same regsvr32 in the IDE, your PATH does not contain the "v70\runtime\win32". I'm not sure how to exactly set the PATH to include "v70\runtime\win32" in Visual Studio .Net 2003. I've tried to add a Post Build Event like:
set path=<path to="" matlab="" mcr="">\v70\runtime\win32";%path%®svr32 "$(TargetDir)"
But the above does not work. Anyone have a solution?
Thanks !
Leslie
|
|
|
|
|
Hi Leslie !
Thanks for the reply.
I don't know if the problem is with the PATH because I register the COM manualy from the console with regsvr32, start a client programm that calls the COM, and get a runtime error. Do you think there is a problem with registration, because regsvr32 reports that everything is fine ?
Take a look at the following link, some guys had a similar problem:
http://www.codeguru.com/forum/showthread.php?t=269478
Regards !
Nedim.
|
|
|
|
|
Hi Nedim,
I guess I have a slightly different problem than you have. My problem is because I don't have the PATH envivronment variable setup correctly. So I created this regDLL.bat file containing:
@echo off
set path=c:\matlab\v70\runtime\win32;%path%
regsvr32 /s /c "c:\projname\debug\MyProj.dll"
if errorlevel 1 goto VCReportError
goto VCEnd
:VCReportError
echo Project : error PRJ0019: A tool returned an error code from "Performing registration"
exit 1
:VCEnd
And I call it from a Post Build Event in Visual Studio and now my registration problem is fixed !
What type of run-time error do you get when you start your application from the console?
Leslie
|
|
|
|
|
Hi Leslie,
Sorry, but I have not been notified about your reply, and today I saw your answer.
I managed the runtime error. It didn't really had nothing to do with the "PRJ0019" error.
So the Visual Studio still gives me:
"error PRJ0019: A tool returned an error code from "Performing registration"
If I register the COM from the console with regsvr32, everything is fine.
I use Matlab 6.0 Rel 12, and there is no folder like
"...\matlab\v70\runtime\win32".
You are probably using Matlab 7.0, that's why there is "\v70". What is the proper folder in the Matlab 6.0, because it has 22 different "win32" folders
Thanks!
Best Regards!
Nedim
|
|
|
|
|
Hi Thankx in advance.
I need some help in embedding DLLs in Matlab.
Can you give me any example to demonstrate this.
ok
pratap
|
|
|
|
|
When trying to compile your project under VC6, i get some errors:
1. i can't find any matlab.h under my C:\MATLAB7\extern\include directory, only mat.h . I assume those work the same?
2. it can't find a file named 'libmatlb.h'. I can find a library named libmatlb.lib under my C:\MATLAB7\extern\lib\win32\microsoft\msvc60 directory however. Do you know how I can fix this error?
Thanks,
Raquel Bujans
|
|
|
|
|
Hi Riazi!
Thanks for all excellent articles!
I have packed some MATLAB code into .dll but later I realized that for the distribution the user has to launch the "mglinstaller" from Mathworks to be able to start my application.
Is there any other way to distribute a MATLAB .dll for use on computer without Matlab Libraries installed.
What are your experiences with distribution? Do I have to pay something to Mathworks if I distribute an application that is using MATLAB libraries?
Thanks !
Nedim.
|
|
|
|
|
mglinstaller can be used in your own installer program to install MATLAB Dlls. The docuemnts also available from Mathworks that how you can employ it.
I did not distribute any MATLAB Dll or library for others and unfortunately I didn't know anything about it.
Please read the Mathworks license agreement!
A. Riazi
|
|
|
|
|
Thank you very much !
I will try to find out what are the rights about distribution of the dll files.
I was reading the Matlab Compiler (version 2.1) and I saw that it is possible to compile the Matlab code into C++ library by
mcc -p -W lib:mylibrary -T compile:lib mycode.m
what I get are files:
mylibrary.hpp
mylibrary.cpp
mylibrary.mlib
There is no ".lib" file !!!! I have expected to get a mylibrary.lib file and to use it like other static libraries with VC++. In the documentation of the M.Compiler it is written that Matlab Compiler can link against a *.mlib file.
So, I would kindly like to ask you,
How do I create statical C++ libraries from MATLAB Code that I can link with VC++ ??
Thanks !
Nedim.
|
|
|
|
|
Hi,
I didn't see any document for compiling MATLAB code to static library! But there are some shareware tools on the net that you can employ to change dynamic libraries to static libraries. Try them.
A. Riazi
|
|
|
|