Click here to get back home

Q: How to make a module with c sourses.

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Q: How to make a module with c sourses. Jae-Hoon Kim 02-03-2005
Posted by Jae-Hoon Kim on February 3, 2005, 7:02 pm
Please log in for more thread options

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.




Posted by Sherm Pendley on February 3, 2005, 5:52 am
Please log in for more thread options
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


Similar ThreadsPosted
mod_perl-1.99_16 won't make: don't know how to make dynamic September 1, 2004, 10:52 pm
Asking questions in 'make test' July 27, 2004, 12:55 am
'make test' strangeness ? August 18, 2004, 4:10 am
GD make test problem November 23, 2004, 6:32 am
Error 255 in make of mod_perl 1.29 November 23, 2004, 2:13 pm
GD make test failure January 16, 2005, 5:11 pm
GD make test failed January 24, 2005, 9:37 am
Compilation problem using make January 21, 2006, 12:49 am
Error in Make Test June 30, 2006, 11:09 am
How can I make entities Not expanded by XML::DOM December 12, 2006, 11:28 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap