in reply to Inline::C better than XS?

A c program, no. A c library yes. <toot>Check out my tutorial</toot> (especially the section titled Exposing a Library). Here's the code snippet from that tutorial:

#!/usr/bin/perl use Inline C => DATA => LIBS => '-lservices'; # Here's how we would configure Inline if our headers and # libraries are in a non-standard location #use Inline C => DATA => # INC => '-I/usr/local/include' => # LIBS => '-L/usr/local/lib -lservices'; my_services(); __END__ __C__ #include <libservices.h> int my_services( ) { struct serv *serv_list = serv_load(NULL); struct serv *serv = serv_list; for (; serv; serv = serv->next) { printf("%s %s %s \n", serv->name, serv->port, serv->proto ); } serv_destroy(serv_list); return 1; }

-derby

Replies are listed 'Best First'.
Re: Re: Inline::C better than XS?
by ginttu (Sexton) on Nov 20, 2002 at 14:28 UTC
    derby,
    foo.c is a program I want to use and call from using Inline. foo.c also uses a library so that foo.c can function. The C code is very long and very complex. I do not want to write it to the bottom of my Inline program.

    Why wouldn't the reply that Zaxo sent work?

    thx, ginttu
      If foo.c contains a "main" function you will likely run into linker problems... You may want to abstract out some of the functionaly of the foo.c into its own library -- this will give you the greatest flexibility.

      --JAS