Shared Libraries 
Author Message
 Shared Libraries

How do I compile Perl code into a shared library?


Wed, 25 Feb 2004 01:35:14 GMT  
 Shared Libraries
That's a big subject, and a broad question. I would suggest you start by
familiarizing yourself with the Object Oriented capabilities in Perl.
You will be more likely to enlist the help of others when you have at
least a general understanding of what you want to do as well as a very
specific question

Good places to start are:

OO Perl by Damien Conway, and
Programming Perl by Larry Wall, et al.

Good Luck.
-Will

Quote:

> How do I compile Perl code into a shared library?



Wed, 25 Feb 2004 11:05:53 GMT  
 Shared Libraries
Wow, I didn't realize it was that big a topic.  I've already got the
subroutines I want to use, I thought I could just compile them.

I guess I should be more specific.  I'm trying to set up a chat
program on a website I'm working on.  This isn't just a simple script
though, it comes with it's own server and allows you to add servlets
to override certain functions by setting up certain functions and
compiling them into a shared library.

I want to set up the library to set up a function called
iServAutheticate that will check my user database and return whether
the user in question is valid or not.

I'm thinking that this shouldn't be too hard of a task to complete -
but the documentation on this is a little fragmented and hard to
understand.

I don't think I need to go out and buy a book for a small task like
this, could you perhaps point me in the direction of a website that
might be able to help me out?

Quote:
>That's a big subject, and a broad question. I would suggest you start by
>familiarizing yourself with the Object Oriented capabilities in Perl.
>You will be more likely to enlist the help of others when you have at
>least a general understanding of what you want to do as well as a very
>specific question



Wed, 25 Feb 2004 11:57:03 GMT  
 Shared Libraries
Perl is a semi-compliled language. Unlike C++ and Java, Perl is not compiled
until runtime. Servlets are associated with Java.

If your functions are already written you can put them in a single script or
put them into a package so they are available to all your scripts.

validate($user, $pw);
This assumes sub validate{ } exists somewhere in your script.

use chat;
use lib '/path/to/library';
chat::validate($user, $pw);
This assumes you have written a package called chat.pm and that it contains a
function called validate.

These are very simple illustrations that barely scratch the surface. As I
said earlier, OO is a big topic. If you are uninterested in buying a book,
you could go to perl.com and perl.org. If you don't know how to access them
on your system, the perl man pages are available on one or both of these
sites.

Good Luck, Smiley.

-Will

Quote:

> Wow, I didn't realize it was that big a topic.  I've already got the
> subroutines I want to use, I thought I could just compile them.

> I guess I should be more specific.  I'm trying to set up a chat
> program on a website I'm working on.  This isn't just a simple script
> though, it comes with it's own server and allows you to add servlets
> to override certain functions by setting up certain functions and
> compiling them into a shared library.

> I want to set up the library to set up a function called
> iServAutheticate that will check my user database and return whether
> the user in question is valid or not.

> I'm thinking that this shouldn't be too hard of a task to complete -
> but the documentation on this is a little fragmented and hard to
> understand.

> I don't think I need to go out and buy a book for a small task like
> this, could you perhaps point me in the direction of a website that
> might be able to help me out?

> >That's a big subject, and a broad question. I would suggest you start by
> >familiarizing yourself with the Object Oriented capabilities in Perl.
> >You will be more likely to enlist the help of others when you have at
> >least a general understanding of what you want to do as well as a very
> >specific question



Wed, 25 Feb 2004 20:56:50 GMT  
 Shared Libraries
Thanks for your help.  I already knot the principles of object
oriented programming, I studied C++ in college.  And I do know about
Perl Modules.  I guess I must be confused about what the chat program
wants.

The documents said that I should compile these functions into a shared
library in Linux, or a DLL in Windows.  I'm only a beginner at Linux
but that's what the server's running off of, so I figured it meant
that there was a way to compile your Perl scripts into a shared
library file.

The documents they sent me were fragmented and didn't give me any
clear-cut instructions, so I'm left to figure some of this stuff out
for myself.

Thanks again for your help, I'm going to contact the company on
Monday.

On Sat, 08 Sep 2001 12:56:50 GMT, William Seeley

Quote:

>Perl is a semi-compliled language. Unlike C++ and Java, Perl is not compiled
>until runtime. Servlets are associated with Java.

>If your functions are already written you can put them in a single script or
>put them into a package so they are available to all your scripts.

>validate($user, $pw);
>This assumes sub validate{ } exists somewhere in your script.

>use chat;
>use lib '/path/to/library';
>chat::validate($user, $pw);
>This assumes you have written a package called chat.pm and that it contains a
>function called validate.

>These are very simple illustrations that barely scratch the surface. As I
>said earlier, OO is a big topic. If you are uninterested in buying a book,
>you could go to perl.com and perl.org. If you don't know how to access them
>on your system, the perl man pages are available on one or both of these
>sites.



Thu, 26 Feb 2004 04:14:06 GMT  
 Shared Libraries

Quote:
> The documents said that I should compile these functions into a shared
> library in Linux, or a DLL in Windows.  I'm only a beginner at Linux
> but that's what the server's running off of, so I figured it meant
> that there was a way to compile your Perl scripts into a shared
> library file.

I think some of the confusion here may be resulting from two different
definitions of "shared library".  William Seeley is approaching the idea
from a "Perl-centric" viewpoint (though I amdit not understanding the
connection between OOP and shared libraries, shared libraries in their many
forms have been around since long before OOP).  Smiley seems to be talking
about a shared library in the more traditional sense - a binary file that
contains executable routines compiled into machine code that can be used by
any program that cares to link to them.

Sicne Perl is a an interpreted language, one doesn't normally work with
compiled binary, but it is possible to work with the compiled machine code
genereated as an intermediate step by the Perl interpreter.  I've never done
it myself, so can't offer many pointers.  The Perl compiler man page might
be the place to start looking
(http://www.perldoc.com/perl5.6/pod/perlcompile.html)

matt

---
The real problem is entropy.



Fri, 27 Feb 2004 17:55:03 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Embeding perl in C++ shared library

2. Shared libraries on IRIX?

3. multi-threaded shared library -> single threaded perl

4. Shared library conflict

5. Makefile.PL and Shared Libraries

6. Modules using shared libraries

7. 5.001 under OSF1/3.0 with shared libraries?

8. error in loading shared Libraries

9. Can not find the shared library libperl.so while executing a C-program using Perl-interpreter

10. Perl with SCO Shared libraries

11. Perl5.001 on RS/6000 AIX3.2 shared library problems

12. Shared Libraries

 

 
Powered by phpBB® Forum Software