Is it possible to add file/product version information to an executable compiled with MCC?

18 Ansichten (letzte 30 Tage)
I’ve been trying to add file/product version information to an EXE file compiled with MCC. Specifically, I'm trying to set the version numbers you see when you right click and get properties on the EXE within Windows Explorer or in the columns in the Details view within an Explorer window. This information is embedded in the EXE in a specific way and I have managed to make it work if I compile as a DLL but I can’t get it to work when compiling as an EXE, which is what I need it to be.
I created a *.res file in Visual Studio 2008 with the necessary information. When I use the following command line to MCC (R2011a) the version information is successfully included, but (obviously?) I get a DLL not an EXE.
-mv myCode.m -l matlabResFile.res
So, I have proven that the res file is correct and it can be done in at least one way. However, I’m can't find the right MCC options to produce the an EXE file with version information.
I’ve done a lot of online searching and the closest I’ve come is this post about changing the icon of an EXE using resource files: It seems to use the –M option but this just does nothing for me.
Is it actually possible to add the Windows explorer compatible version information at compile time and if so how can it be done? (I know I could use a 3rd party tool after compilation but I’m trying to avoid this)
Thanks, Matt

Akzeptierte Antwort

Matt am 22 Sep. 2011
I ended up having to contact mathworks support as we needed an answer quickly. They said...
"The "compilation" in MATLAB Compiler is quite a bit different for DLLs and standalones. When creating a DLL you are indeed actually compiling C/C++ code and then you can indeed add a resource script/file to include version information. When compiling a standalone however, MATLAB Compiler works with a precompiled launcher so it is not possible to compile a resource script into it. You can add resources afterwards though using tools like "ResHacker"."

Weitere Antworten (2)

Aurelien Queffurust
Aurelien Queffurust am 9 Sep. 2011
To display the versioning of my standalones , I am using the flags -R -startmsg -completemsg with mcc
For more details , see on my blog how I used these flags with the helloworld example.
  1 Kommentar
Matt am 9 Sep. 2011
Thanks very much for your answer Aurelien. It’s good and correct, but sadly is not what I need. This is my fault for not being descriptive enough in my question, which I’ve now updated.

Melden Sie sich an, um zu kommentieren.

Arthur am 21 Mai 2012
I had a similar problem; we wanted our own icon in the executable and we wanted a splash screen while waiting for MCR to start. I have my own C launcher that draws the splash, then starts MCR and hands off to M-code. We are able to build using a single MCC call with the LCC compiler shipped with MATLAB. You should be able to work out something similar for MSVC. The trick with LCC is to pass these arguments to MCC to include the resource file:
mcc( ...
'-M', 'LINKFLAGSPOST=-subsystem windows $LINKFLAGSPOST shell32.lib myProduct.res', ...
'-W', 'lib:myProduct', ...
'-T', 'link:exe', ...
'myProduct.m', ...
'main.c' ...
It took a lot of trial and error with MCC -v to figure out the right arguments, but that does the trick for me.
  1 Kommentar
Steven Steltenpool
Steven Steltenpool am 17 Okt. 2012
Hello Arthur,
I'm trying to do the same with showing a splash screen, with the difference that the MCR console will not be show (hence the need for a splash screen). I’m using a .res (with MSVC) file for the Icon for a long time now, but we need to move a step further. Any chance you can share any of the C launcher code with us here or with me?
Thanks, Steven

Melden Sie sich an, um zu kommentieren.


Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by