http://www.perlmonks.org?node_id=510773

JamesNC has asked for the wisdom of the Perl Monks concerning the following question:

My perl is ActiveState 5.8.7 build 813.
I do not encounter any issues running this code on an older version of Visual Studio C++. This problem only happens with the newer (free) enviroment ( as in there is no such thing as free beer I suspect ).
I downloaded and installed the free Visual C++ tools at: http://lab.msdn.microsoft.com/express/visualc/ and the new Platform SDK (which you need).
Then, I did a quick and dirty test.

1. h2xs -A -n myModule
2. perl Makefile.pl 3. edit myModule.xs
#include "EXTERN.h" #include "perl.h" #include "XSUB.h" int test ( int a ) { return a; } MODULE = myModule PACKAGE = myModule int test( int a )
4. nmake
(I only got 1 warning about -Gf being deprecated, so I looked up the error and changed the flag to -GF and it compiles with out error. All good so far. )
5. nmake install
6. open up the editor and write a quick script where I call the brain-dead function.
use strict; use myModule; my $var = myModule::test(123); print $var;
7. When I run the script I get a VC++ runtime error:
C:\Perl\bin\perl.exe R6034 An application has made an attempt to load the C runtime library + incorrectly.
And perl dies complaining:
Can't load 'C:/Perl/site/lib/auto/myModule/myModule.dll' for module my +Module: load_file:A dynamic link library (DLL) initialization routine failed at C:/Perl/lib/XSLoa +der.pm line 68. at C:/Perl/site/lib/myModule.pm line 31 Compilation failed in require at c:\progs\ptest.pl line 1. BEGIN failed--compilation aborted at c:\progs\ptest.pl line 1.

Question 1: Does anyone know what is broken and how to fix it?

Question 2: I can see that the -Gf flag needs to be fixed, how to I make the change so that when I use h2xs in the future that that flag is fixed?
Thanks!
JamesNC
Update and solution:
The solution is to create an XML file called perl.exe.manifest and place it in the same directory as your perl.exe and put the following contents in that file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1. +0"> <assemblyIdentity version="0.0.0.0" processorArchitecture="X86" name=" +Perl" type="win32" /> <description>Perl</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version +="8.0.50215.4631" processorArchitecture="x86" publicKeyToken="1fc8b3b +9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependency> </assembly>
Thanks to everyone who helped. Especially ++Pod Master.
JamesNC