Solved

Custom Perl Modules from API/Headers

Posted on 2007-03-19
9
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Six Sigma Control Plans

626 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