Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Calling C-Code from Perl

by aykun81 (Sexton)
on May 17, 2008 at 16:34 UTC ( #687107=perlquestion: print w/replies, xml ) Need Help??

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

Hello, I have a project which requires that I run a c-code inside a perl code. Inline module seems to be the perfect solution for me. Though, I have a problem that I haven't been able to solve by myself. Well I said to myself: "Let's start from the simplest case so that I can see if the module really works or not". So I created a pl file named dene.pl (after successfully installing the inline module) and put the following code into it:
#!C:\Perl\bin\perl.exe use Inline C => <<'END_C'; void greet() { printf("Hello, world!"); } END_C greet();
Now when I type "perl dene.pl", I get an error message which says: "msvcr90.dll could not be found, try to reinstall the app". I checked which c compiler perl is using and it turns out that it's using cl.exe which comes along with Microsoft Visual Studio ++. I have checked if I can successfully compile the c-code itself using cl.exe and the result is: Yes I can. However, no matter what I did, I couldn't get the perl code to run. I really need help here urgently. Thanks in advance. Note: I have the mentioned dll file many places which I think are the right places for the file to be (C:\Windows\winSxS\x86_Microsoft.VC90.CRT_1fc....\; C:\MSVC9\VC\redist\x86\Microsoft.VC90.CRT\ etc.)

Replies are listed 'Best First'.
Re: Calling C-Code from Perl
by mwah (Hermit) on May 17, 2008 at 17:58 UTC

    Let's guess:

    You have Activestate Perl 5.8.x installed on a Win-XP system and you try to do Inline C-stuff, but Inline C's build system now finds Visual Studio 2008 (cl) as your primary compiler.

    I'm not sure this will work, mainly because your Activeperl is compiled most probably w/Visual Studio 98 (msvc 6) and can't load modules compiled w/<insert your compiler>.

    (Just guessing)

    Regards

    mwa

      hmmm so you are suggesting that I should try installing Visual Studio 98 instead of the latest version? worth a shot...
Re: Calling C-Code from Perl
by syphilis (Bishop) on May 18, 2008 at 00:31 UTC
    So I created a pl file named dene.pl (after successfully installing the inline module)

    How did you install Inline::C ? It would be better that you install it by building from source, rather than using PPM.

    If you did build it from source, then you should have got the same error (a number of times) when 'nmake test' was being run. It seems you can get good milage out of VC9 with ActivePerl, but you will probably need to do the following if you're running perl 5.8.x:
    1) Update ExtUtils::MakeMaker to version 6.42_01;
    2) Change the 'ccversion' entry in Config_heavy.pl to whatever version is reported when you run 'cl'.

    To test that your compilation environment is set up correctly, try installing a perl extension (such as Math::FFT). Inline::C errors are sometimes not very helpful when it comes to diagnosing problems with the compilation environment.

    Cheers,
    Rob
Re: Calling C-Code from Perl
by Anonymous Monk on May 17, 2008 at 19:21 UTC
Re: Calling C-Code from Perl
by Anonymous Monk on May 17, 2008 at 19:23 UTC
    Did you run vcvars32?
Re: Calling C-Code from Perl
by aykun81 (Sexton) on May 19, 2008 at 16:33 UTC
    Hey thanks everyone! problem solved!.. an earlier version of VC (VC6) solved the issue... thanks to everyone who posted a comment

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://687107]
Approved by randyk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2021-05-15 11:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?