|
Hello
function z=Sum(x,y)
z=x+y;
end
mcc -W lib:mylib -T link:lib Sum.m
loadlibrary('mylib.dll','mylib.h');
z=[];
calllib('mylib','mlfSum', 1, z, 10, 20);
output (z) is zero. why?
|
|
|
|
|
Hello
I have three functions (.m files)[Sum.m and Multiplication.m and subtraction.m]
and i want a package of them (.dll)[foe example p.dll].
1-How do i create a package of them?
2-How i call this dll file in my program?(matlab space)
|
|
|
|
|
|
my code looks like this:
mxArray* rresult;
mxArray* xx;
mxArray* yy;
FFTMatlabLibInitialize();;
xx = mxCreateDoubleMatrix(1, 5, mxREAL);
double myArray[5]={10.2, 3, 6.3, 5.4, 5.9};
memcpy((void *)mxGetPr(xx), (void *)myArray, 5 * sizeof(double));
At the last statement the code breakes with error:
"An unhandled exception of type 'System.AccessViolationException"
"Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Also, when I put a break point there to see the veriables before it crashes, I get xx = <undefined value="">
I would appreciate any solution.
|
|
|
|
|
This application has failed to start because libmatlb.dll was not found, re install application may fix this problem.
I download ur demo code and tried to execute on vc++6.0, but am facing this problem how could i solve??? please help me...
|
|
|
|
|
hi,
how to convert m files matlab to dll for use in c#.net?
|
|
|
|
|
سلام آقای ریاضی
می تونید این مطلب رو برای استفاده با ویژوال سی 2008 بروز کنید
ممنون
|
|
|
|
|
Hallo everyone.
It takes me a lot of work to make cooperation MATLAB 6.5 and C++ Builder.It works for small m-files but not with real functions.
I wrote script which use rgb2gray and imabsdiff Image Processing Toolbox. While Builder enter to my function and try to enter to code like this :
mlfAssign( &laserLine, mlfNImabsdiff(0, mclValueVarargout(),
mlfRgb2gray(mclVa(backgroundImage, "backgroundImage"), NULL, NULL),
mlfRgb2gray(mclVa(laserImage, "laserImage"), NULL, NULL),
NULL));
I get this kind of problem:
Access violation at address xxxxxxxxxxx in module 'libmatlib.dll'. Read of address 00000018.
I try to debug it, but I think this command is taken from .dll file so I can't debug it. I try to copy dll file do project, include it, but I always get the same problem.
I also add before and after recall my function:
InitializeModule_xxxx and TerminateModule_ but I do not get any reaction. Do I have to call all InitializeModule_ methods form all files created by mcc????
And at the begin of file I have something like this:
#include "excretelaserline.h"
#include "excretelaserline_lib.h"
#include "C:\MATLAB6p5\extern\include\matlab.h"
#include "C:\MATLAB6p5\extern\include\matrix.h"
#pragma comment(lib,"C:\MATLAB6p5\extern\lib\win32\borland\bc54\libmx.lib")
and without those files it will not compile, so they have to be added.
I also add to Project:
- excretelaserline.c and .h,
- excretelaserline_lib.c, .h and .lib
- libmatlb.lib
- libmmfile.lib.
So where is bug. If libmatlb.dll is correct. Do You know solution?
|
|
|
|
|
actually we are doing our degree project. we have a part of matlab in our project but now we can`t integrate matlab code with c#. we have done finger print recognition code and we want to call it throug c#. so kindly reply me soon. i m waiting thanks
nasir rashid
|
|
|
|
|
Hi, is there anyway I can use MATLAB .DLL to generate random numbers in C#? If yeh then what is the library file named? And what is the name of the class inside it?
I'm doing research on random number generated in different programming language, like VC++6, .NET and so on...
Any help would be appreciated
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
my application is made in vc and it uses matlab generated c/c++ libraries.
but when i run my exe files in a computer that has only .net framework 2, the part of application that has vc code runs fine, but when i click button to open a dialog made in matlab, it says couldnot initialize application.
it runs fine if matlab is installed in the computer.
so do we have something like matlab framework ? or someone have faced and solved similar problem, please do inform,
thank you.
|
|
|
|
|
|
Asalam o alaikum
Glad to know you are also a Muslim. I am from Pakistan.
I am using the command you given below in Matlab 7.0
mcc -t -L C -W lib:MeanFunctionLib -T link:lib MeanFunction.m libmmfile.mlib
but it gives me error at right at the start that cannot find this libmmfile.mlib
but I renamed it to libmmfile.lib then it works and generate files but before finishing gives me the error that this file cannot be found.
From where I can found this file or fix this issue?
Similary in your demo project, I did not find the following lib files neither in your demo project zip or in matlab directory:
<br />
#pragma comment(lib, "libmx.lib")<br />
#pragma comment(lib, "libmatlb.lib")<br />
#pragma comment(lib, "libmat.lib")<br />
#pragma comment(lib, "libmmfile.lib")<br />
Note here you used libmmfile.lib not libmmfile.mlib
Any ways I run my mcc command given below for an m file that contains a function name probabilistic in a file named probabilistic.m
mcc -v -t -L C -W lib:probabilistic -T link:lib probabilistic.m
After running this command I got the following files
probabilistic.c
probabilistic.h
probabilistic.exports
probabilistic.ctf
probabilistic_mcc_component_data.c
probabilistic.dll
probabilistic.exp
probabilistic.lib
I also copied the following files from matlab installation into my current directory
tmwtypes.h
mclmcr.h
matrix.h
created a project in VC and included all files and built solution. I created a new file with following code:
<br />
#include "probabilistic.h"<br />
<br />
#pragma comment(lib, "probabilistic.lib")<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
probabilisticInitialize();<br />
<br />
mlfprobabilistic();<br />
<br />
probabilisticTerminate();<br />
<br />
return 0;<br />
}<br />
It give the following compilation warning message
<br />
--------------------Configuration: probabilistic - Win32 Debug--------------------<br />
Compiling...<br />
runner.c<br />
C:\MATLAB7\work\runner.c(13) : warning C4013: 'mlfprobabilistic' undefined; assuming extern returning int<br />
<br />
runner.obj - 0 error(s), 1 warning(s)<br />
And it gives me the following linking errors.
<br />
--------------------Configuration: probabilistic - Win32 Debug--------------------<br />
Linking...<br />
probabilistic.obj : error LNK2001: unresolved external symbol _mclInitializeComponentInstance<br />
probabilistic.obj : error LNK2001: unresolved external symbol _mclmcrInitialize<br />
probabilistic.obj : error LNK2001: unresolved external symbol _mclTerminateInstance<br />
probabilistic.obj : error LNK2001: unresolved external symbol _mclFeval<br />
probabilistic.obj : error LNK2001: unresolved external symbol _mclMlfFeval<br />
runner.obj : error LNK2001: unresolved external symbol _mlfprobabilistic<br />
Debug/probabilistic.exe : fatal error LNK1120: 6 unresolved externals<br />
Error executing link.exe.<br />
<br />
probabilistic.exe - 7 error(s), 0 warning(s)<br />
I think the whole problem is because of this starting libmmfile.mlib or libmmfile.lib.
Waiting for sharp reply.
Thanks
Junaid
|
|
|
|
|
I have the same problem with unresolved external symbols. Waiting for a reply..
|
|
|
|
|
can any one help me on matlab .net builder
anyone reply who work on matlab c#.net
I hav a lot of queries to ask, I m new to this technology
|
|
|
|
|
Dear Riazi,
I read your documents and samples. I thing they are very benefit for everybody. Thank you I enjoyed that IRANIAN people shining in the world. I will appreciated you to your answer.
I have some problem in compiling the MeanFunction.cpp. I have installed MATLAB704 with typical mode.
1- When I compile your sample project I have problem in the header files same as “libmatlbm.h and libmatlb.h” VC compiler can’t find these files.
2- When create CPPLIB files and I compile it in C++ builder there are some errors in linking same as “can not resolve the __MCC_M01_name_data, ….“.
3- When create C LIB files and I compile it in C++ builder there is not any error but I have not any output value in the variables after run the MeanFunction as follw:
static mxArray *yy[10],*result;
static mxArray *xx;
double myArray[5]={11.2, 3, 6.3, 5.4, 5.9};
char buffer[100],*Str1;
xx=mxCreateDoubleMatrix(1, 5, mxREAL);
memcpy(mxGetPr(xx), myArray, 5 * sizeof(double));
MeanFunctionInitialize();
mlfMeanFunction (1,yy,xx);
Dreal=mxGetPr(yy[0]);
if(Dreal)
{
sprintf(buffer," y= %f ", Dreal[0]);
ShowMessage(buffer);
}
MeanFunctionTerminate();
Of course your switches in mcc compiler don’t approve so I made my c and cpp files by these switches, I don’t know they are correct or no.
mcc -W lib:M01 -T link:lib MeanFunction.m
mcc -W cpplib:M01 -T link:lib MeanFunction.m
Pls reply to VH_ROSTAMI@YAHOO.COM
Your Sincerely Vahid Rostami
Best Regard
|
|
|
|
|
can i use matlab inbuild function ..witahut instaling matlab in my system
it means i develop dll, lib, .h file from matlab system now i try to use this in other where no matlab install so is this possible ...?
chetan
|
|
|
|
|
As I know, it isn't.
You must have instaled same version of Matlab, or you may try just to install MCRInstaller.exe which is located somewhere in Matlab directory. You will find detailed informations in Matlab help.
Program that you build required this files even if you set your linker to build libraries into exe file. I don't know much about that.
|
|
|
|
|
hi!
I have a dll that has not the header file(.h). So how can i calling this dll in matlab. I`m proffesinal in vb but have little experience in matlab.
please help me to this.
thanks.
|
|
|
|
|
I compiled simle Matlab m-file into dll using C++ lib, but there is a problem when I try to initialize exported function in c++ project.
For example, my dll is called DllFun, and I call initializer with DllFunInitialize(), it's return false. ApplicationInitialize return true.
Is it problem with compatability with Borland???
|
|
|
|
|
I must reply on my own message...
First, two very important things; one is that "treat enum types as ints" must be checked in compiler. This thing enables us to use classID in constructor of array class. second is that file .cft must be presented together with .lib, .h and .dll (for dimamically linking only, I think). So, this steps are:
1. Compile m-file in matlab:
mcc -W cpplib:mylib -T link:lib libfile1.m libfile2.m ...
<mylib> is name of library, <libfile> is name of m-file.
2. Copy .lib, .cft, .h, .dll files in project or included directory.
3. Add matlab INCLUDE and LIB directory in project options -> directories
4. Add mclmcr.lib and mylib.lib files in project
4,5. Add "#include "mclmcr.h" and "mylib.h" n program.
5. Check "treat enum types as ints" in compiler options
It is possible to create mwArray without this, but without classID declaration in constructor. This allow us to manipulate with array using operator (), for example:
mwArray A(2, 2); A(1, 2)= 5;
but we cannot use methods like SetData, or use that array in function call.
6. Call mlfApplicationInitialize(), then call FunctionNameInitialize() for each function.
7. Continue work with application as you do.
Forgive me if I miss something.
There is still more unresolved questions:
- why CPU window displays each time when I run application from Builder,
- why ApplicationInitialize() is so slow?
|
|
|
|
|
Hi... I need import a dll for builder to
I follow all steps and when i compile this mensage error appear
"[Linker Error] Unresolved external '_mylibInitialize' referenced from D:\FACULDADE\PROJETO FINAL\CBUILDER\UNIT1.OBJ"
can you help me ????
|
|
|
|
|
Compiler tells you that there is a declaration of function '_mylibInitialize' in your unit or some included header file and have definition in some external file you did not included into project.
You didn't included mylib.lib, and there is a reference in mylib.h.
Go to the menu, under the Project item select Add to Project.. and find this library in dialog box.
Remember, you must include mclmcr.lib, too.
|
|
|
|
|
I have an example in Cpp, but project is too big (about 3.5MB), and I can't upload it to the my site. If you send me a mail, I will send it to you.
|
|
|
|
|
Hi ,
I am trying to compile a simple matlab function to shared library. I have used
following option.
mcc -t -L C -W lib:MeanFunctionLib -T link:lib MeanFunction.m libmmfile.mlib
Following error got generated.
"mcc -t -L C -W lib:MeanFunctionLib -T link:lib MeanFunction.m libmmfile.mlib
The filename, directory name, or volume label syntax is incorrect.
LINK : fatal error LNK1104: cannot open file "_lib3223.def"
LINK : fatal error LNK1141: failure during build of exports file
??? Error using ==> mbuild
Unable to complete successfully
??? Error: An error occurred while shelling out to mbuild (error code = 1).
Unable to build executable (specify the -v option for more information).
Error in ==> C:\MATLAB6p1\toolbox\compiler\mcc.dll"
Kindly let me know , if I am using the correct option or not.
regards.
Kumar Shwetaketu
India.
|
|
|
|
|