|
|
I use matlab 6.5 and MS .NET 7.0 and I've done the following two trial:
In my console application (.NET and WIN) and use:
- your original .dll function MeanFunction.
- MY own .dll function that use your original .dll function MeanFunction.
It is OK.
But if I use in MATLAB
mcc -t -L C -W lib:MeanFunctionLib -T link:lib MeanFunction.m libmmfile.mlib
to produce .dll then MATLAB generate different (wrong) MeanFunctionLib.dll file. I get a running mistake. Everything is the same. But MATLAB generate wrong file. I use default compilator.
Do you have an idea ... ???
|
|
|
|
|
Hi,
I have some question, please help me:
1. I did all steps as you show. But in VS C++ 6.0 :
mxArray* sum;
mxArray* x;
mxArray* y;
double myArray[2]={5, 10};
x = mxCreateDoubleMatrix(1, 1, mxREAL);
y = mxCreateDoubleMatrix(1, 1, mxREAL);
memcpy(mxGetPr(x), myArray, sizeof(double));
memcpy(mxGetPr(y), myArray+1, sizeof(double));
MySumFunctionLibInitialize();
sum = mlfMysumfunction(x, y);
MySumFunctionLibTerminate();
lfPrintMatrix(sum);
mxDestroyArray(x);
mxDestroyArray(y);
mxDestroyArray(sum);
At the 5th line, when I debug, it have a error "The instruction at "0x00017b00" referenced
memory at "0x00017b00. The memory could not be "read" ", and my application terminates.
2. Why MathLab Add-in can't compile in Windows Server 2003, but ok in Windows 2000 ?
3. How can I use MatLab function in VS C++ 6.0 ?
4. Is there only one type variable connect between MatLab and VC ?
Thanks.
123
|
|
|
|
|
I am using Matlab R13 and MSVC 6.0
I can successfully compile my .m file into .h .dll and .lib. All of them are of C-style, i.e. the data type are mxArray. Is it possible to compile them in C++ style (mwArray)?
I tried -L cpp options but it doesn't work even in the simplest case:
% Here is "test.m"
% function a = test(b)
% a = b+1;
mcc -t -L cpp -W lib:testlib -T link:lib -h test.m libmmfile.mlib
mcc says:
--> "link "/out:testlib.dll" kernel32.lib user32.lib gdi32.lib advapi32.lib oleaut32.lib ole32.lib /LIBPATH:"D:\MATLAB6p5\extern\lib\win32\microsoft\msvc60" libmatlb.lib /nologo libmx.lib libmat.lib libmwservices.lib libmex.lib libut.lib /dll /implib:"testlib.lib" /def: D:\MATLAB6p5\extern\lib\win32\libmatpm.lib @7444_tmp.rsp "
LINK : fatal error LNK1146: no argument specified with option "/def:"
MBUILD.BAT: Error: Link of 'testlib.dll' failed.
??? Error using ==> mbuild
Unable to complete successfully
??? Error: An error occurred while shelling out to mbuild (error code = 1).
Unable to build executable.
Error in ==> D:\MATLAB6p5\toolbox\compiler\mcc.dll
Thanks in advance.
|
|
|
|
|
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
|
|
|
|