Solved

Custom Perl Modules from API/Headers

Posted on 2007-03-19
9
364 Views
Last Modified: 2011-09-20
Platform: Linux/Windows XP
Perl

I'm trying to learn how to create perl modules. I have the header files and the .lib and .dll files.  I've been programming perl for about a year now and I'm ready to start creating my own modules.  Can someone point me in the right direction on how to create a perl extension to interface with an api.  
0
Comment
Question by:TristinColby
  • 5
  • 4
9 Comments
 
LVL 2

Accepted Solution

by:
fpintos earned 500 total points
ID: 18753770
0
 
LVL 1

Author Comment

by:TristinColby
ID: 18753894
So is it possible to create an extension using only the headers and a precompiled .lib or .dll?  Looking at the SWIG docs it looks like it only works if you have the full function definitions.
0
 
LVL 2

Expert Comment

by:fpintos
ID: 18753937
You don't need the source of the library or dll to create an extension. You only need to create the wrapper code which basically handle the conversion of perl function call parameters to C parameters, and handle any error correctly.
0
 
LVL 1

Author Comment

by:TristinColby
ID: 18753944
so once I write the wrapper code would I just do a    use lib "mylib.lib'?    Do you know of somewhere I can get an example from?  You know. the whole shabang. the wrapper and how to call it once I'm through coding the wrapper.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:fpintos
ID: 18753966
Please look at the section 21.3.4 from the doc, http://www.unix.org.ua/orelly/perl/prog3/ch21_03.htm. It is exactly what you need. Inside the wrapper code, it is calling math routine from the external math library. You need to specify the external library in LIBS in the makefile, in this case -lm

You can also look at further examples from the Perl XS tutorial by doing a "perldoc perlxstut".
0
 
LVL 1

Author Comment

by:TristinColby
ID: 18753976
Page Deleted, or so it says. :)
0
 
LVL 2

Expert Comment

by:fpintos
ID: 18753993
Which page are you referring to? http://www.unix.org.ua/orelly/perl/prog3/ch21_03.htm is still there.

I was looking at the section as I typed the earlier reply.

If you are referring to perlxstut, it should come with your perl installation.
0
 
LVL 1

Author Comment

by:TristinColby
ID: 18754013
hmm. Mine says page deleted when I click on the link. just tried it again. what book is it. I can just dl it.
0
 
LVL 2

Expert Comment

by:fpintos
ID: 18754024
It is chapter 21 from the camel book "Programming Perl".

Did you look at perlxstut? It has more examples there than the book.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now