This post originated from an RSS feed registered with Ruby Buzz
by Daniel Berger.
Original Post: Dealing with MS Visual Studio's manifest file
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
The latest release of Microsoft's Visual Studio C/C++ compiler generates something called a manifest file whenever you generate a DLL or shared object. If you're building your application from within the Visual Studio tool itself this isn't a problem, because it will embed the manifest for you.
However, if you're building from the command line you must do this manually. If you don't you'll end up seeing an error like this:
"ruby.exe - Unable to Locate Component - This application has failed to start because MSVCR80.dll was not found. Re-installing the application may fix this problem."
I found posts here and here that helped immensely. That latter goes on in some detail about what manifests are, side-by-side assemblies, etc, if you really want the nitty gritty details.
The solution, it turns out, is to use the poorly documented 'mt' command line utility that comes with Visual Studio. Say you've got a foo.c source file, you've run extconf.rb and you have both a foo.so and foo.so.manifest file sitting on your filesystem. In order to embed the manifest file within the shared object you would run this command:
In short, specify a manifest file and the shared object to embed it into. See the second link I provided above if you want to know what the '#2' means. Just know that it *must* be '#2', and don't forget the semicolon.
After that, you should be able to load your shared object without issue.
The question now is, how should mkmf.rb handle this? I vote to check for the compiler version and automatically embed the manifest into the shared object as a post link step if cl 14 or later is found. Another option would be to add a 'embed_manifest' method that we would be expected to call manually after the 'create_makefile' method call.