Solved

Custom Perl Modules from API/Headers

Posted on 2007-03-19
9
371 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
Industry Leaders: 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 and use switch statements in the C programming language.

739 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