Author Topic: VC++ and embedded manifests  (Read 4521 times)

Offline johne53

  • Regular
  • ***
  • Posts: 253
VC++ and embedded manifests
« on: November 11, 2009, 11:28:53 am »
Recent versions of Visual C++ have demanded that programs which use the C runtime (and various other resources) should use a "manifest". The manifest can be embedded into the app or it can be a separate file which has to be distributed along with the executable.

When I select (say) VC++2005 as my compiler, C::B makes it generate a separate manifest file but I believe the general preference is for an embedded manifest. Is there a command I can add to my options that will specify an embedded manifest?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: VC++ and embedded manifests
« Reply #1 on: November 11, 2009, 03:47:38 pm »
Is there a command I can add to my options that will specify an embedded manifest?
Yes.

Prebuild steps:
Code
"%VS80COMNTOOLS%vsvars32.bat" x86
"%MS_SDK%\SetEnv.Cmd" /XP32 /RETAIL

Post build steps:
Code
mt.exe -manifest "$(TARGET_OUTPUT_FILE).manifest" /outputresource:"$(TARGET_OUTPUT_FILE)";1

You have to adjust the path's to match your VC compiler / MS SDK though... though.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: VC++ and embedded manifests
« Reply #2 on: November 13, 2009, 02:31:37 pm »
Thanks Morten. The prebuild step seems to be giving me a problem. I assume that VS80COMNTOOLS and MS_SDK need to be set up as environment variables but when I attempt a build I get this output from C::B:-

Quote
Running target pre-build steps
"E:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat" x86
Setting environment for using Microsoft Visual Studio 2005 x86 tools.
"\SetEnv.Cmd" /XP32 /RETAIL
Execution of '"\SetEnv.Cmd" /XP32 /RETAIL' in 'F:\ardour2\libs\libsndfile' failed.
Nothing to be done.

If I'm interpreting this currectly, the call to vsvars32.bat is succeeding whereas it seems to be looking for SetEnv.Cmd in my project's folder, instead of its actual folder. I've checked my environment variables. VS80COMNTOOLS is defined whereas MS_SDK isn't. However, I can't find out where VS80COMNTOOLS is defined. It gets referenced by vsvars32.bat but where is it being defined? It isn't anywhere in my registry or in any "ini" file or any "bat" file AFAICT. Or (more correctly I suppose) why doesn't MS_SDK seem to be defined??

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: VC++ and embedded manifests
« Reply #3 on: November 13, 2009, 02:38:28 pm »
Or (more correctly I suppose) why doesn't MS_SDK seem to be defined??
That was a place-holder I added there because originally there was the path to *my* installation.

However - I am not sure if you need the prebuild-steps at all. In fact they should be pretty useless and setting the environment is local for this very call only and does not persist the C::B session (thanks god).

The most important aspect is calling "mt" with the macro parameters as described. "mt" needs the environment to be setup correctly. So probably you do the call of "mt" in a batch file (calling the pre-build steps and then the "mt" command) and setup the post-build step in C::B to call this very batch file. This should work very reliable.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: VC++ and embedded manifests
« Reply #4 on: November 13, 2009, 08:30:13 pm »
Thanks Morten. I must admit I was a bit puzzled about why the pre-build step was needed but now that I've removed it, the post-build stage does seem to work just fine!