Solved

Custom Perl Modules from API/Headers

Posted on 2007-03-19
9
366 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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
 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
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.

786 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