f



How to transfer matlab codes into visual c++ or c codes?

Hi, Folks

I have written some matlab functions (Matlab 6.5), and I want to
change them into visual c++ or c codes then create a visual c++
project to use the generated c++ or c codes.(visual c++ 6.0).

Could anyone give me the full instructions on how to deal with it
because I have met some unresolved external symbol problems when
linking (use visual c++ 6.0).

Have I missed to include some lib files?

Thanks.
0
ysun4 (2)
6/14/2004 8:00:54 PM
comp.soft-sys.matlab 211266 articles. 22 followers. lunamoonmoon (257) is leader. Post Follow

2 Replies
1078 Views

Similar Articles

[PageSpeed] 32

Hi,

Suppose you have an M-file mySquare.m:
function y = mySquare(x)
y = x*x ;

You'll create a dll file by using the command:
mcc -t -L C -W lib:mySquarelib -T link:lib mySquare.m libmmfile.mlib

Matlab will create nine files for you:

mysquare.c mysquare.h mysquarelib.c
mySquarelib.dll mySquarelib.exp mysquarelib.exports
mysquarelib.h mySquarelib.lib mysquarelib.mlib

Then you can call like this:

....
/* call the initial function */
mySquarelibInitialize() ;

/* call the implementation function */
y_ptr = mlfMysquare(x_ptr);

/* call the termination function */
mySquarelibTerminate() ;

We have tested, it worked fine in Visual C++ 6.0 and .Net.
Hope it helps.

LePhan

----------------------------------------------
See our MATLAB C/C++ Book at:
www.LePhanPublishing.com

Yi Sun wrote:
>
>
> Hi, Folks
>
> I have written some matlab functions (Matlab 6.5), and I want to
> change them into visual c++ or c codes then create a visual c++
> project to use the generated c++ or c codes.(visual c++ 6.0).
>
> Could anyone give me the full instructions on how to deal with it
> because I have met some unresolved external symbol problems when
> linking (use visual c++ 6.0).
>
> Have I missed to include some lib files?
>
> Thanks.
0
LePhan (62)
6/14/2004 11:40:21 PM
You need to purchase the MATLAB compiler to run this command.
-evan

xmblade wrote:
>
>
> Hi,
> I also met the same problem. And when i deal with it following
> your
> mentioned steps, some problems arise as follows. How can I fix it?
> Thanks a lot!
>
> The below is the information report. The information from the [29]
> to
> the end is marked as red.
>
> ------------------------------------------------------------
>
>>>mcc -t -L C -W lib:mySquarelib -T link:lib mySquare.m
> libmmfile.mlib
>
>
--------------------------------------------------------------------
> ----
> Segmentation violation detected at Mon Jul 26 14:05:27 2004
>
--------------------------------------------------------------------
> ----
>
> Configuration:
> MATLAB Version: 6.5.0.180913a (R13)
> Operating System: Microsoft Windows XP
> Window System: Version 5.1 (Build 2600: Service Pack 1)
> Processor ID: x86 Family 15 Model 2 Stepping 9, GenuineIntel
> Virtual Machine: Java 1.3.1_01 with Sun Microsystems Inc. Java
> HotSpot(TM) Client VM
> (mixed mode)
>
> Register State:
> EAX = 00000000 EBX = 00df72a0
> ECX = 00000000 EDX = 00df60cc
> ESI = 258d6544 EDI = 255cc224
> EBP = 00df60fc ESP = 00df60ec
> EIP = 021642f8 FLG = 00010293
>
> Stack Trace:
> [0] common_context.dll:_internal_remove(0x00df7278, 0x258d6544,
> 0x255cc224 "mySquare", 0x00df7278) + 88 bytes
> [1] common_context.dll:_fmgrReResolve(0, 0, 0x258d6544, 0) + 50
> bytes
> [2] common_context.dll:_fmgrResolveInfoForMex(0x00df7278, 0,
> 0x258d6544, 0x255cc224 "mySquare") + 26 bytes
> [3] compiler.dll:_com_get_Mfile_record_for_function(0x00df6ae4,
> 0x014b01a0, 0x255cc22d "mySquare.m", 0) + 415 bytes
> [4] compiler.dll:_process_user_specified_m_files(0x00df6ae4,
> 0x00df6950, 0x00df6950, 0x00df6ae4) + 77 bytes
> [5] compiler.dll:_M2CCpp(0x00df6950, 0x00df6a84 "���",
> 0x020ff549,
> 0x00df6ae4) + 96 bytes
> [6] compiler.dll:_M2Target(0x00df6ae4, 0x00dfafcc, 0x00dfd1cc,
> 0x014d6d90) + 46 bytes
> [7] compiler.dll:_run_compiler_common(0x00dfd1cc, 0x00dfafcc,
> 0x00df6a5c, 0x00df6a3c) + 1081 bytes
> [8] compiler.dll:_compiler(0x00dfafcc, 0x020e15a6, 39, 10) + 232
> bytes
> [9] mcc.dll:_try_compile(0x00dfd1ac "�i�", 0x00dfd19c, 0,
> 0x00dfd1f9
> "��") + 58 bytes
> [10] libut.dll:_ut_try_catch(0x00dfd1ac "�i�", 0x00dfd19c,
> 0x020e14e0, 0x020e1520) + 61 bytes
> [11] mcc.dll:_mexFunction(10, 0x00dfd5d0, 0, 0x00dfd6d4) + 546
> bytes
> [12] libmex.dll:_mexRunMexFile(0, 0x00dfd5d0, 9, 0x00dfd6d4) + 71
> bytes
> [13] m_interpreter.dll:void __cdecl inCallMexFunction(int,struct
> mxArray_tag * * const,int,struct mxArray_tag * * const,void
> (__cdecl*)(int,struct mxArray_tag * * const,int,struct mxArray_tag
> * *
> const),struct _mex_context *,struct mexfiles *)(0, 0x00dfd5d0, 9,
> 0x00dfd6d4) + 476 bytes
> [14] m_interpreter.dll:void __cdecl inRunMexFile(int,struct
> mxArray_tag * * const,int,struct mxArray_tag * * const,struct
> mexfiles
> *)(0, 0x00dfd5d0, 9, 0x00dfd6d4) + 126 bytes
> [15] m_interpreter.dll:void __cdecl inExecMexFile(int,int,struct
> mxArray_tag * * const,struct MATLAB_Function_tag *)(0, 9,
> 0x00dfd6d4,
> 0x014d6d90) + 82 bytes
> [16] m_interpreter.dll:_inExecFunction(0, 9, 0x00dfd6d4,
> 0x014d6d90)
> + 38 bytes
> [17] m_interpreter.dll:_inMMexExecute(549, 0x014d6d90, 0, 9) +
> 533
> bytes
> [18] m_interpreter.dll:enum opcodes __cdecl inMMex(char const
> *,int,int,int,int *,int *)(0x014adc1c "mcc", 549, 0, 9) + 94 bytes
> [19] m_interpreter.dll:int __cdecl inInterp(enum
> inDebugCheck,int,int,struct inPcodeNest_tag volatile *)(2, 0, 0,
> 0x013b4c90) + 2143 bytes
> [20] m_interpreter.dll:_inInterPcode(2, 0x00dfdc54, 0, 0) + 193
> bytes
> [21] m_interpreter.dll:enum inExecutionStatus __cdecl
> in_local_call_eval_function(int *,struct _m_parser_interface
> *,struct
> _pcodeheader *,int *,struct mxArray_tag * * const,enum
> inDebugCheck)(0, 0x7a87fa78, 0x00dfdc54, 0x00dfdcf8) + 174 bytes
> [22] m_interpreter.dll:_inEvalStringWithIsVarFcn(0x0ad5ccc0 "mcc
> -t
> -L C -W lib:mySquarelib -..", 69, 0, 0) + 531 bytes
> [23] m_interpreter.dll:_inEvalString(0x0ad5ccc0 "mcc -t -L C -W
> lib:mySquarelib -..", 69, 0, 0) + 50 bytes
> [24] m_interpreter.dll:enum inExecutionStatus __cdecl
> inEvalCmdWithLocalReturnandtype(char const *,int *,enum
> inDebugCheck)(0x0ad5ccc0 "mcc -t -L C -W lib:mySquarelib -..", 0,
> 2,
> 0x00dfde30) + 68 bytes
> [25] m_interpreter.dll:_inEvalCmdNoEnd(0x0ad5ccc0 "mcc -t -L C -W
> lib:mySquarelib -..", 1, 0x0047f617, 11) + 16 bytes
> [26] matlab.exe:_mnParser(0x70a71a39, 271244, 0, 48) + 1001 bytes
> [27] matlab.exe:_WinMain@16(4194304, 0, 271244, 1) + 3872 bytes
> [28] matlab.exe:_WinMainCRTStartup(0x70a71a39, 0x80000002,
> 0x7ffdf000, 0xef517cf0) + 3
> 08 bytes
> [29] kernel32.dll:0x77e814c7(0x0047172c, 0, 0, 0)
>
> This error was detected while a MEX-file was running. If the
> MEX-file
> is not an official MathWorks function, please examine its source
> code
> for errors. Please consult the External Interfaces Guide for
> information
> on debugging MEX-files.
>
> If it is an official MathWorks function, please
> follow these steps in reporting this problem to The MathWorks so
> that we have the best chance of correcting it:
>
> 1. Send this crash report to segv@mathworks.com for automated
> analysis.
> For your convenience, this information has been recorded in:
> C:\DOCUME~1\g0202313\LOCALS~1\Temp\matlab_crash_dump.4024
>
> 2. Also, if the problem is reproducible, send the crash report to
> support@mathworks.com along with:
> - A specific list of steps that will reproduce the problem
> - Any M, MEX, MDL or other files required to reproduce the
> problem
> - Any error messages displayed prior to this crash report
> A technical support engineer will contact you with further
> information.
>
> Thank you for your assistance. Please save your workspace and
> restart
> MATLAB before continuing your work.
>
> Error in ==> C:\MATLAB6p5\toolbox\compiler\mcc.dll
>
>
>
>
> On Mon, 14 Jun 2004 19:40:21 -0400, LePhan wrote:
>>Hi,
>>
>>Suppose you have an M-file mySquare.m:
>>function y = mySquare(x)
>>y = x*x ;
>>
>>You'll create a dll file by using the command:
>>mcc -t -L C -W lib:mySquarelib -T link:lib mySquare.m
> libmmfile.mlib
>>
>>Matlab will create nine files for you:
>>
>>mysquare.c mysquare.h mysquarelib.c
>>mySquarelib.dll mySquarelib.exp mysquarelib.exports
>>mysquarelib.h mySquarelib.lib mysquarelib.mlib
>>
>>Then you can call like this:
>>
>>...
>>/* call the initial function */
>>mySquarelibInitialize() ;
>>
>>/* call the implementation function */
>>y_ptr = mlfMysquare(x_ptr);
>>
>>/* call the termination function */
>>mySquarelibTerminate() ;
>>
>>We have tested, it worked fine in Visual C++ 6.0 and .Net.
>>Hope it helps.
>>
>>LePhan
>>
>>----------------------------------------------
>>See our MATLAB C/C++ Book at:
>>www.LePhanPublishing.com
>>
>>Yi Sun wrote:
>>>
>>>
>>> Hi, Folks
>>>
>>> I have written some matlab functions (Matlab 6.5), and I
want to
>>> change them into visual c++ or c codes then create a visual
c++
>>> project to use the generated c++ or c codes.(visual c++
6.0).
>>>
>>> Could anyone give me the full instructions on how to deal
with
> it
>>> because I have met some unresolved external symbol problems
when
>>> linking (use visual c++ 6.0).
>>>
>>> Have I missed to include some lib files?
>>>
>>> Thanks.
>
>
0
evan2409 (24)
7/27/2004 12:28:55 AM
Reply:

Similar Artilces:

Shall i use the misrosoft Visual c++ code from a m-file generated from matlab in Visual C++ with out matlab runtime environment
undefined ...

calling Matlab code from C/C++ code
Hi, I am learning to call Matlab code from C/C++ code. Here are my questions (1)are using Matlab engine and converting Matlab code into a C or C++ shared library the only two ways? (2) what's the difference between these two methods? Advantages and disadvantages? In what case use which method is better? Thanks and regards! On Mon, 03 Aug 2009 10:33:00 -0400, Tim <timlee126@yahoo.com> wrote: > Hi, > I am learning to call Matlab code from C/C++ code. Here are my > questions > > (1)are using Matlab engine and converting Matlab code into a C or C++ > shared library...

C/C++ in matlab and matlab in C/C++ ?
Is it possible to read C/C++ code in matlab and the other way around too? Hi, as long as C or C++ are written in text files you can edit them in the matlab editor. To see the special character of C or C++ coding language, in the editor go to menus: file>preferences>Edito/Debugger>language and on popup "Language" select "C/C++". This does not allow you to run the C/C++ code, just to view it i nicer way... regards, chris saneman <asdfsdf@asd.com> wrote in message <frl846 $f8i$2@news.net.uni-c.dk>... > Is it possible to read C/C...

matlab codes to visual C# code
Hi all, I am just wondering if it is possible to convert a matlab code to C#? ...

Matlab face detection code to c/c++ code
hello guys... I am in urgent need of something which can change my MATLAb code to C or C++ code. I have to run this C, c++ code in Code composer studio and feed the program into DSP emulator EVDM642. Code composer studio does not support MATLAB... So, its important to convert the code into C or C++.. This is my semester project and I have to give the presentation on 18th november...or else I will be failed.. Please help me guys....Tell e something which changes MATLAb to C/C++. Thanx in advance. On 16 Nov., 05:42, "Tarun " <tarunsa...@gmail.com> wrote: > hello guys... >...

MATLAB algorithm to MATLAB function code or C code
hallo firends, Can any body help me write this below code into MATLAB object oriented code or C code form please? M=50; % total number of periods. (choose for 1s duration) f0 = 50; % fundamental AC frequency T0 = 1/f0; %fundamental AC period T = M*T0; %Time for M periods (integer M) N=30; % sample points per period. dt = T0/N; % Sample at N points per period (integer N > 20) t = dt*[1:M*N-1]; % Sampling time array A0=120/2; % amplitude of AC signal. Divide by 2 or maybe sqrt (2) ? AC=A0*sin(f0*t*2*pi); % create AC signal. DC0=50; % DC amplitude DC=DC0*ones(1,le...

how to change matlab code to Visual C++ code
Hi, I would like to know how to change matlab code to visual C++ code , I heard that matlab has mcc funtion, What is it and how to use? many thanks! Yvonne Ho wrote: > Hi, > I would like to know how to change matlab code to visual C++ code , I > heard that matlab has mcc funtion, What is it and how to use? > many thanks! doc mcc would be a good start... Why do you want to do this? Stuart "Yvonne Ho" <yvonnegarden@gmail.com> wrote in message news:eefa000.-1@webx.raydaftYaTP... > Hi, > I would like to know how to change matlab code to visual C++ code , I &g...

converting c++ code to Matlab code using Matlab 9
im working on a project using matlab. i want to use some of the already writen codes in C++. i want to use these codes in my project rather than writing them from scratch. is there some way or a chunk of code that might convert C++ code to matlab code or a ".c" file to ".m" file. please if anyone knows do let me know at the earliest.thanks "fatima " <fatima_naseem2002@yahoo.com> wrote in message <i8ugqn$e9p$1@fred.mathworks.com>... > im working on a project using matlab. i want to use some of the already writen codes in C++. i want to use these c...

coverse a Matlab.mdl into C / C++ code and how to use this code
Hello help, I am a dutch student which want to integrate a simply matlab.mdl in a C++ program. But how do I do that? I have one in and output. In the model there will be added a constant to this input. So its just a simple example to learn how to integrate generated code into C or C++. I did the same by labview and there was a clearly guide for doing this. Building DLLs in LabVIEW 6.x or later: <http://zone.ni.com/devzone/conceptd.nsf/webmain/5df85b448eb081d8862568ff006a0b20> Calling a DLL from Microsoft Visual C++ that Was Generated by LabVIEW 6i: <http://zone.ni.com/devzone/de...

MATLAB code to C code
Hi all I read a similar question posted by someone else but my situation is slightly different. I am porting some MATLAB code to C code. I need to find a way to read jpeg images in C just as imread does in MATLAB. The problem is that I have tried a number of C libraries, but they do not serve my purpose completely. I want to read simple grayscale jpeg images into unsigned interger arrays. Can someone pls shed some light. Thanks Qaseem ...

Matlab code to C-code
If I want to generate C-code from m-file not specifically for embedded target, which tool can I use? As of I know emlc converts embedded MATALAB code to C-code. Does the Real-Time Workshop uses emlc? Please any one tell me how can I convert my m-file (not only embedded m-file) to C- code. Hi Naveen, i don't think you can do this. if you could, TMW would be giving away the store! you can, however, use the MATLAB Compiler to generate a DLL that you can call from C. MCC will generate a little stub that you call. That stub will call into the MCR (MATLAB Component Runtim...

C code from MATLAB code
Hi I have a complex algorithm that eventually will be encoded in C to run on a DSP or Controller (e.g. Hitachi SH4). The present MATLAB implementation under WINDOWS calls advanced standard MATLAB routines such as fft, matrix factorizations, eigenvalue solvers, fmincon (for nonlinear optimization subject to nonlinear constraints), and some number theoretic functions. I figure that the transcription to an optimized C code requires many months of hard labor. Before I embark on this adventure, I would like to generate from my MATLAB code (as easily as possible, i.e. as automatically as possible) ...

Possible to execute a Objective C or C/C++ Code through MATLAB?
I have a Objective C Code which performs a certain function. I would like to run the code through MATLAB. If Objective C is not compatible with MATLAB and C or C++ is, then the code could be converted to C/C++. I am not a C/C++ person, so please do let me know if MATLAB is capable to handling this. Thanks, Nevine If you can call if from regular C code you can use a mex file. http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f29502.html Stuart "Nevine Jacob" <nevinejacob1981@hotmail.com> wrote in message news:ef17b4e.-1@webx.raydaftYaTP... >I have a O...

M code into programming C code or MATLAB programming code
hallo firends, Can any body help me write this below code into MATLAB object oriented or C code form please? M=50; % total number of periods. (choose for 1s duration) f0 = 50; % fundamental AC frequency T0 = 1/f0; %fundamental AC period T = M*T0; %Time for M periods (integer M) N=30; % sample points per period. dt = T0/N; % Sample at N points per period (integer N > 20) t = dt*[1:M*N-1]; % Sampling time array A0=120/2; % amplitude of AC signal. Divide by 2 or maybe sqrt (2) ? AC=A0*sin(f0*t*2*pi); % create AC signal. DC0=50; % DC amplitude DC=DC0*ones(1,length...

Web resources about - How to transfer matlab codes into visual c++ or c codes? - comp.soft-sys.matlab

Charge-transfer complex - Wikipedia, the free encyclopedia
A charge-transfer complex ( CT complex ) or electron-donor-acceptor complex is an association of two or more molecules , or of different parts ...

Hot money transfer app WorldRemit just bagged an extra £31 million
Hot UK money transfer app WorldRemit has secured a $45 million (£31 million) line of credit from US growth fund TriplePoint Venture Growth and ...

Hot money transfer app WorldRemit is doing 400,000 transfers a month
Hot UK money transfer app WorldRemit has secured a $45 million (£31 million) line of credit from US growth fund TriplePoint Venture Growth and ...

Facebook faces restrictions in France on data transfer to US, tracking of users
The French data protection authority has ordered Facebook to stop some transfers of personal data of its users to the U.S. and to change the ...

Facebook faces restrictions in France on data transfer to U.S.
... et des Libertés, at a press conference in Brussels on Feb. 3. The French data protection authority has ordered Facebook to stop some transfers ...

MoneyGram To Pay $13M, Revamp Policies To Protect Against Wire Transfer Fraud
... to zap money from our bank accounts to our friends and family members with the touch of a button, some people continue to rely on money transfer ...

Dwolla White Labels Its Bank To Bank Transfers To Avoid Credit Card Fees
Dwolla is offering a white label API for firms that want to send or receive payments while protecting their own brand.

EXPLOSIVE HANDOFF? Video captures possible Somalia bomb transfer
EXPLOSIVE HANDOFF? Video captures possible Somalia bomb transfer

Fugitive Jail Inmate Facing Transfer Back to Los Angeles
A murder suspect who authorities say was mistakenly released from a California jail won't fight his transfer in custody from southern Nevada ...

Sanjay Kapur cites mafia threat to seek divorce case transfer to Delhi
Bollywood actress Karisma Kapoor’s estranged husband Sanjay Kapur has moved the Supreme Court asking it to transfer a case pertaining to their ...

Resources last updated: 2/14/2016 12:57:35 AM