Solved

Custom Perl Modules from API/Headers

Posted on 2007-03-19
9
361 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them 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.

705 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

18 Experts available now in Live!

Get 1:1 Help Now