On Sep 12, 2006, at 2:58 PM, Karthika Arunkumar wrote:

Thanks,Sure .
1.When I use std::string datatype of c++ in the constructor, perl is not recognising the constructor and gives error 'cannot locate new'.So I have used char*.

2.This code when used as stand alone script with hashbang(#!) line works fine.But when I add 'pachage chkthr; and 1; to make it a module gives error 'cannot locate object method new via package thready.(perhaps you forgot to load thready)'.

3.The calling script had ' use chkthrd; '   and then '&chkthrd::call;'

The simplified code (reproducing error) follows:
package chkthrd;
use Inline CPP;
sub call{
my $ip = "192.168.1.10";
my $ab = new thready($ip);
$ab->start();
$ab->joining();}
__END__
__CPP__
class thready
     {    private:
        pthread_t mythr;
                char* id;
          public:
                thready(char* idstr){id=idstr;std::cout<<id;}
        ~thready(){std::cout<<"over";}
                void start(){std::cout<<"start"}
        void joining(){std::cout<<"join"}
      };
1;

to avoid the error I wrote main too in C++ (creating object too in c++ and called start and joining from c++).But how do I call that function from other module, if I switch to that solution?

Thanks a lot for any help,
kararu.




You should probably have posted that follow up to the inline list as there are people there much more knowledgeable than myself. If I had to hazard a guess, I'd say that there's some sort of package name mangling going on when Inline::CPP is used within a module. What version of perl is this? I haven't used the CPP inline module, but I'll install it and see if I can get a feel for whats going on.


--
J.


Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to