all
I have test.m( matlab source code) file which implement A() function; and main.cpp file (will call A() ).
as you know ,we may do like the following steps:
use matlab to compile test.m (mcc -) ,will generate : test.dll, test.ctf,test.h .
copy the test.dll and test.ctf ,test.h file to VS2005 project. in main.cpp, call A() in test.dll.
But,when i release the programe,i will also pack the test.dll together.
And another way, can i using the VS2005 to compile both test.m and main.cpp which will only generate main.dll,main.ctf,main.h..( i will only release main.dll,main.ctf,main.h,).
this means, i compile the test.m into main.cpp.
And i have tried this way, in VS2005 ---> Build Events--> pre-Build Event-->command line: mcc C -w lib:test test.m
and it will generate the mid-file test.ctf(only test.ctf,no test.dll).But i don't know how to compile test.ctf into main.cpp ?
could anyone help me ?
thanks.
You can do it the other way around and add your main.cpp to the matlab build process: I don't know the exact syntax, but you can add your main.cpp to mcc/mbuild, and it will add it to the dll for you. When using deploytool in gui mode, just drag c/c++ files to the resources area and they get compiled into the dll. So you'll have one dll only containing both m code and your own c++ code.
Another option, using the above strategy: first try the above, and look at the output of deploytool: it will show you the commands used. First it invokes mcc, then mbuild which in turn calls cl (the MS compiler). Use the exact command used to invoke mcc as a pre-build event, and then add that output files to cl in the same way mbuild does it (you can also see in the output how it does that). This way you can use VS to build a single dll anyway, just mimick what the matlab build process does.
Still I'm not sure how this is beneficial over distributing the two seperately. Also don't forget you have to distribute the entire MCR with it else your clients won't be able to run any code using the dll.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With