|
|
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
|
|
|
|
|
|
Hi,
I searched +- the entire net, and didn't found any of these tools !?!.
*Can you give an example please?
*And, how should you set into visual studio 6 to link staticly (a non-mfc program....) ??
PS: love your article
kekkezek
|
|
|
|
|
|
Thanks a lot!
It might be a dumb question,
but does this means that
a .dll->always dynamic
a .lib->always static
???
|
|
|
|
|
This means you can convert DLL (dynamic link library) to LIB (static link library)!
A. Riazi
|
|
|
|
|
|
Hello ,
I tried with this tutorial to compile a simple function test.m , into a dll.
I'm using matlab 6.1 , Release 12.1 and MS VC++ 5.
My matlab function :
function OUT=test(PIC);
OUT=PIC-1;
Quiet difficult to make simplier ...
Then I used, the command line given in the tutorial
mcc -t -L C -W lib:TestLib -T link:lib -h test.m libmmfile.mlib
and I got 8 files
test.c
test.h
TestLib.c
TestLib.exp
TestLib.exports
TestLib.h
TestLib.lib
TestLib.mlib
Someone formerly said he got 9 files: he got a dll file too
Anyone knows where it disappeared ?
Then I follow
the tutorial and successfully compiled my project.
But when executing , MS VC++ claims TestLib.dll
Anyone got any advise ?
Thanks
|
|
|
|
|
Hi,
I've made a dll file with the matlab compiler, and now I have to access its functions in visual basic 6.
But I keep getting error messeges, like "cant find entry point". I also have had problems with the variable types, Matlab uses arrays even for integer numbers.
Can anyone help please?
It's for a school project.
thanks.
skin the sun, fall asleep, wish away, soul is cheap, lesson learnt, wish me luck, sooth the nerve, wake me up
|
|
|
|
|
|
I got the error messages in visual basic.
VC ++ compiled with out errors.
When I try to use the dlls, either from matlab or vc++ i got errors, saying that the function didn't exist, or the entry point error in vb 6.
Also, I read your articles, which are very good, but I don't seem to have the com toolbox in matlab. I have version 6.0
I appreciate your help.
skin the sun, fall asleep, wish away, soul is cheap, lesson learnt, wish me luck, sooth the nerve, wake me up
|
|
|
|