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

18 views (last 30 days)
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: http://www.mathworks.co.uk/support/solutions/en/data/1-324E1D/index.html?solution=1-324E1D. 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

Accepted Answer

Matt
Matt on 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"."

More Answers (2)

Aurelien Queffurust
Aurelien Queffurust on 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 Comment
Matt
Matt on 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.

Sign in to comment.


Arthur
Arthur on 21 May 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 Comment
Steven Steltenpool
Steven Steltenpool on 17 Oct 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

Sign in to comment.

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!