• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

PERL: Using Inline C for Windows - Urgent!

Hello,

  I am trying to get Inline C working on my computer. I get the following error when I try to run:

  use Inline C;
    greet('Ingy');
    greet(42);
    __END__    
    __C__
    void greet(char* name) {
      printf("Hello %s!\n", name);
    }


   Which is basically a "hello world" program and I should imagine would work the first time.

   The error is:
C:\OCR\Dev>perl testInlineC.pl

Microsoft (R) Program Maintenance Utility   Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

        C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils/xsubpp  -typemap C:\Perl\lib\ExtUtils\typemap  testInlineC_pl_6a6
f.xs > testInlineC_pl_6a6f.xsc && C:\Perl\bin\perl.exe -MExtUtils::Command -e mv testInlineC_pl_6a6f.xsc testInline
C_pl_6a6f.c
        cl -c  -IC:/OCR/Dev  -nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT
-DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -MD -Zi -DNDEBUG -O1
   -DVERSION=\"0.00\"  -DXS_VERSION=\"0.00\"  "-IC:\Perl\lib\CORE"   testInlineC_pl_6a6f.c
testInlineC_pl_6a6f.c
C:\Perl\lib\CORE\perl.h(380) : fatal error C1083: Cannot open include file: 'sys/types.h': No such file or director
y
NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2'
Stop.

A problem was encountered while attempting to compile and install your Inline
C code. The command that failed was:
  nmake > out.make 2>&1

The build directory was:
C:\OCR\Dev\_Inline\build\testInlineC_pl_6a6f

To debug the problem, cd to the build directory, and inspect the output files.

 at testInlineC.pl line 0
INIT failed--call queue aborted.



Things to note:

1. I saw http://www.experts-exchange.com/Programming/Programming_Languages/Perl/Q_20939245.html?query=Inline+C+in+perl&clearTAFilter=true already and followed the steps that Kandura noted.

2. My path is:
C:\OCR\Dev>path
PATH=c:\program files\imagemagick;c:\program files\sdb\programs\bin;c:\program files\sdb\programs\pgm;C:\WINDOWS\sy
stem32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;c:\perl\bin;c:\mysql\bin;C:\Program Files\ActiveState Komodo 3.0\;C:\Per
l\bin\;c:\Python22;C:\Program Files\M
icrosoft Visual Studio .NET\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\Bin;C:\Progra
m Files\Microsoft Visual Studio .NET\Common7\Tools\Bin\winnt;C:\Program Files\Microsoft Visual Studio .NET\vc7;C:\P
rogram Files\Microsoft Visual Studio .NET\Vc7\bin;c:\program files\Microsoft Visual Studio .Net\Common7\IDE\;

3. cl.exe and link.exe are both at: C:\P
rogram Files\Microsoft Visual Studio .NET\Vc7\bin which is in my path.

4. The error is slightly different than what ShakeySteve encountered. I admit that my original error was the same as his; it was only after I did the same steps he took that I got the error message above:

C:\Perl\lib\CORE\perl.h(380) : fatal error C1083: Cannot open include file: 'sys/types.h': No such file or director
y
NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2'
Stop.

  are the new lines in the error message. I'm not sure how to proceed.

 

   Thanks in advance for any help you might give! I'd really like to get Inline C working.

   sapbucket

0
sapbucket
Asked:
sapbucket
  • 7
  • 4
1 Solution
 
plqCommented:
Isn't it the 42 ? You can only pass it a char * which means that '42' would be ok but not 42 without the quotes
0
 
sapbucketAuthor Commented:
That isn't it. I commented out greet(42); and I still get the same error message.
Something is wrong with the linking and compiling.

I tried searching for types.h and it was at c:\program files\Microsoft Visual Studio .Net\vc7\sys so I added that folder to my path. The script still didn't work because I still get the same error: "Cannot open include file: 'sys/types.h'".

I then opened perl.h and changed the include statement to the FULL path to where types.h is. LO AND BEHOLD - it had a new error message:

C:\Perl\lib\CORE\perl.h(391) : fatal error C1083: Cannot open include file: 'stdarg.h': No such file or directory
NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2'
Stop.


Which is just the next include statement in perl.h.


SO, how do i specify the #include so that I do not have to use full filepath names? Is there a system variable (i would guess called INCLUDE) that C++ uses? The #include ignores the system PATH variable already because I HAVE all these folders in PATH.

Where the heck does C++ "look" when compiling #include statements? I do not know C++ but in PERL if I needed anything I would push @INC the path to the folder I want.

I looked up here on experts exchange and found:
<QUOTE>
You have 3 possibilities

1)
You can place the complete path to the file, something like.....

#include "c:\development\myProj\Include\xxx.h"

2) If the include directory is a directory where include files from all projects can be included

you can do

Tools -> Options -> Projects -> VC++ Directories -> Include files and add the directory there.

3) you can do nonubik suggestion.
Suggestion number 2 would be the same as using number 3 for every project you use in Visual Studio......
</QUOTE>

And I tried 1.) and it worked, but now I have to do this for every #include???!?! THat is crazy. I also tried 2.) and it looked great - I included the folders needed - but even after that things were not working.



Thanks again anyone.

sapbucket


0
 
sapbucketAuthor Commented:
Progress:

I found INCLUDE and LIB system variables. I copied and pasted the paths of include statements that throw an error. This got me through compilation - now I need to address the paths for the linker.


LINK : fatal error LNK1181: cannot open input file 'oldnames.lib'
NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x49d'
Stop.

OK,
C:\OCR\Dev>perl testInlineC.pl
Hello Ingy!


YAHHAHAHAH! It works.


So can anyone explain why I had such problems with the paths for all the files? Why did I have to do this by hand and why isn't it automatically accomplished?

C is so strange. Everytime I deal with it it takes about 50-100 times longer to generate a solution then with PERL. Go figure.


0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
plqCommented:
I dont do perl but every 9 months or so I write a few thousand lines of C and then forget it all again ... and I always get grief about include files and paths. I've never managed to consistently make something work first time yet although there's probably loads of people on here who understand it well enough (or have enough spare time) to get it working first time !!

glad it works anyway
0
 
plqCommented:
I think you would should your points back on this if you raise a question in community support.
0
 
plqCommented:
should=get ! sorry
0
 
sapbucketAuthor Commented:
OK, I never did understand the whole points thing. I just pay the monthly fee to ask questions. Says I have "unlimited" points on my login page.

How should I go about assigning the points? How do I "raise a question in community support"  plq?

Any user or admin know what I should do with these 500 points? I answered my own question.

sapbucket
0
 
plqCommented:
If you have paid then you have unlimited points it doesn't really matter if you give them to me or get them back. I have the points I need for this month so it wont make any difference to me either. To get your points back you have to raise a question in the community support topic area and paste a link to this question

http://www.experts-exchange.com/Community_Support/

this Q = http://www.experts-exchange.com/Programming/Q_21201452.html#12550704
0
 
plqCommented:
Dont want a grade C. Please ask community support to give your points back

thanks
0
 
sapbucketAuthor Commented:
plq,


   if you walk me through it I will - I'm not sure what "community support" is.

0
 
plqCommented:
I have asked community support to refund for you.

http://www.experts-exchange.com/Community_Support/Q_21206749.html
0
 
CetusMODCommented:
Unaccepted per request http:Q_21206749.html

Question PAQ'd
500 points refunded.

CetusMOD
Community Support Moderator
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now