|
سلام آقای ریاضی
می تونید این مطلب رو برای استفاده با ویژوال سی 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.
|
|
|
|
|
Someone please help me to do this
i have my algorithms written in Matlab.
i want to call my matlab algorithms in my C program so that i can sent values to my matlab code and get the result.
i dont want to use the matlab engine to do it.
i would like to use the matlab compiler option to do that.
if anyone can help me plz explain me with an example code
i have a compiler version of 4.6 and a matlab version of 7.4.
i am using visual studio 2005 for doing my c program
please do help me
sindhu
|
|
|
|
|
Hello,
This is my first time using M-Files within my C++ code.
We another group that creates the M-files and I would like to know if I need to make a DLL for every single M-File or they can be grouped and one DLL can be created for multiple M-Files? If that's the case, how can I tell which M-files can be combined into one DLL?
Thank You,
|
|
|
|
|
I want to compile matlab image processing function such as imread, imshow to DLL, and then I want to use that DLL java project
but always i have this error message :
Warning: File: affiche Line: 2 Column: 5
References to "imread" will produce a run-time error because it is an undefined
function or variable.
how i can compile the m files and use them in java project?
Please help me.
thanks.
|
|
|
|
|
You must consider that you can't compile all matlab codes including those that related to eval function, GUI and structures. The imread uses many of them and you can't compile it.
Best regards,
A. Riazi
|
|
|
|
|
Hi Riazi,
I saw your article on creating the DLL and *.lib (mean calculation code) from *.m file and using it with the C/C++ code. I tried with the Matlab Version 6.1 Release 12.1 and it worked.
However, when I try code with MATLAB 7, I fail to compile the code. Seems the matlab 7 does not have "matlab.h" header itself along with some lib files. How can use the DLL with Matlab 7.
Kindly help in this regard.
with respect.
Kumar Shwetaketu
India.
|
|
|
|
|
Hi! I tried the same procedure as in the article...
I wrote my m-file and compiled it with
"mcc -B csharedlib:libmy myFuncr.m -v" and then I made a little program in C to use the dll I had created...I can compile it but when running it I got an access violation error at a line where I'm trying to create a mxArray *:
<br />
mxArray* in1 = NULL;<br />
mxArray* in2 = NULL;<br />
<br />
in1 = mxCreateDoubleMatrix(4,4, mxREAL); <big>Here I get the error</big>
the error I get say "Project xxxxx.exe raised exception class EAccessViolation with message 'Access violation at address 00000000.Read of address 00000000'"
I'm using borland to compile (Borlan c++ builder 6) and matlab version 7.
Can you help me? Thanks!
|
|
|
|