warlock has asked for the wisdom of the Perl Monks concerning the following question:
-----------------------/tmp/prova2/helloworld/helloworld.xs-----------------------# Makefile MODULE=helloworld TYPEMAP=/usr/local/lib/perl5/5.8.7/ExtUtils/typemap XSUBPP=/usr/local/lib/perl5/5.8.7/ExtUtils/xsubpp PERLCORE=/usr/local/lib/perl5/5.8.7/i686-linux/CORE CC=gcc .PHONY: init clean all : init libhelloworld.so init : perl -e "use Devel::PPPort; use ExtUtils::Constant q +w (WriteConstants); \ Devel::PPPort::WriteFile(); WriteConstants(NAME => ' +$(MODULE)')" libhelloworld.so : helloworld.o $(CC) -shared helloworld.o -o $@ helloworld.c : helloworld.xs perl $(XSUBPP) -typemap $(TYPEMAP) helloworld.xs >$@ helloworld.o : helloworld.c $(CC) -Wall -fPIC -I$(PERLCORE) -I. -c helloworld.c +-Wl,-rpath,. -o $@ clean : rm -f helloworld.o helloworld.c const-c.inc const-xs +.inc ppport.h clean-all : clean rm -f libhelloworld.so
-----------------------/tmp/prova2/helloworld/helloworld.pm-----------------------#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include <helloworld.h> #include "const-c.inc" #include "extlibs/myprint.h" //#include "extlibs/myprint.c" MODULE = helloworld PACKAGE = helloworld INCLUDE: const-xs.inc void helloworld_proc() CODE: printf ("Helloworld\n"); boxing_print ("Helloworld");
-----------------------/tmp/prova2/helloworld/extlibs/Makefile---------------------package helloworld; use 5.008007; use strict; use warnings; use Carp; require XSLoader; our $VERSION = '0.01'; XSLoader::load('helloworld', $VERSION); 1;
-----------------------/tmp/prova2/helloworld/extlibs/myprint.c----------------------# Makefile localpath=/tmp/prova2/helloworld/extlibs LD_RUN_PATH=$(localpath) CC=gcc .PHONY: clean clean-all all : libmyprint.so test myprint.o : myprint.c $(CC) -c myprint.c -Fpic -o $@ libmyprint.so : myprint.o myprint.h $(CC) -shared myprint.o -o $@ test : test.c $(CC) -Wall test.c -I$(localpath) -L$(localpath) -Wl +,-rpath,$(localpath) -lmyprint -o $@ clean : rm -f *.o clean-all : clean rm -f *.so test
-----------------------/tmp/prova2/helloworld/extlibs/myprint.h-----------------------#include "stdio.h" #include "string.h" #include "myprint.h" void boxing_print (char *st) { int t=0; for (t=0; t<strlen(st); t++) printf ("-"); printf ("\n%s\n", st); for (t=0; t<strlen(st); t++) printf ("-"); printf ("\n"); return; }
Thank you for your help. Best regards Warlockvoid boxing_print (char*);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: shared-obj linking in xs-module
by rafl (Friar) on Mar 16, 2006 at 13:25 UTC | |
by warlock (Initiate) on Mar 16, 2006 at 13:53 UTC | |
by rafl (Friar) on Mar 16, 2006 at 14:02 UTC | |
by warlock (Initiate) on Mar 16, 2006 at 14:19 UTC | |
by rafl (Friar) on Mar 16, 2006 at 14:32 UTC | |
|