Home > Archive > PERL Modules > February 2005 > Q: How to make a module with c sourses.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Q: How to make a module with c sourses.
|
|
| Jae-Hoon Kim 2005-02-10, 3:56 am |
|
I'm going to make a module with c sources, which consist of 5 header (*.h)
files,
13 source (*.c) files, and a makefile.
To solve the problem, '*.c' and '*.h' files are included in 'm.xs', then it
works.
I do not think that THIS IS AN ANSWER!".
Here is a very small example which I want;
Makefile -----------------------------------------
CC = gcc
CFLAGS =
OBJS = main.o lib.o
main: $(OBJS)
main.o: main.c *.h
lib.o: lib.c *.h
clean:
-rm main
-rm $(OBJS)
lib.h -----------------------------------------
int PrintHello();
lib.c -----------------------------------------
#include <stdio.h>
#include "lib.h"
int PrintHello(char *name) {
printf("Hello, %s!\n", name);
return 1;
}
main.c ----------------------------------------
#include <stdio.h>
#include "lib.h"
int main() {
char *name = "Aha00a";
PrintHello(name);
return 0;
}
-----------------------------------------------
My goal is to use a Perl script as following;
iwanna.pl -------------------------------------
use strict;
use MyLib::Hello;
my $name = "Aha00a";
PrintHello($a);
-----------------------------------------------
Thanks in advance.
| |
| Sherm Pendley 2005-02-10, 3:56 am |
| Jae-Hoon Kim wrote:
> I'm going to make a module with c sources, which consist of 5 header (*.h)
> files,
> 13 source (*.c) files, and a makefile.
>
> To solve the problem, '*.c' and '*.h' files are included in 'm.xs', then
> it works.
> I do not think that THIS IS AN ANSWER!".
You're right - it's not. Trying to create your own Makefile manually is an
exercise in frustration. Don't do it.
Instead, start with h2xs - even if you don't actually convert your .h files
with it, it will still create a "skeleton" module for you, that uses the
standard "perl Makefile.PL; make; make test; sudo make install" procedure
to build, test, and install.
Have a look at the following to get started:
perldoc perlxstut
perldoc h2xs
perldoc ExtUtils::MakeMaker::Tutorial
perldoc ExtUtils::MakeMaker
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
|
|
|
|
|