1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Inline::Struct : Error : Cannot Locate Object method via new

Discussion in 'Perl' started by Tango Issac Debian, Mar 21, 2009.

  1. Tango Issac Debian

    Tango Issac Debian New Member

    Joined:
    May 3, 2006
    Messages:
    31
    Likes Received:
    1
    Trophy Points:
    0
    This is a very simple code I trying to run after installing the Inline::C pacakges by the APT in the ubuntu system. The Hello World level programm is running successfully. To use the Inline::Struct for this simple code, I facing a problem.

    Code:
    #!/usr/bin/perl -w
    
    #use Inline C;
    use Inline C => Config => Structs => ['Foo'];
    use strict;
    
    
    
    
      my $obj = Inline::Struct::Foo->new;
      $obj->num(10);
      $obj->str("Hello");
    
      myfunc($obj);
    
      __END__
      __C__
      
      #include<stdio.h>
    
      struct Foo {
        int num;
        char *str;
      };
    
      void myfunc(Foo *f) {
        printf("myfunc: num=%i, str='%s'\n", f->num, f->str);
      }
    
    

    This Code showing this specific error during runtime :

    Code:
    "Can't locate object method "new" via package "Inline::Struct::Foo" (perhaps you forgot to load "Inline::Struct::Foo"?) at /home/tango/workspace/PerlLerning/structFromPl.pl line 10."
    

    What is the possible solution??
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:

Share This Page