SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Building C/C++ libraries with Perl

    Alberto Manuel Brand˜o Sim˜es
                        a     o
            ambs@perl.pt



           YAPC::EU::2012




        Alberto Sim˜es
                   o     Building C/C++ libraries with Perl
Disclaimer



                              This is my point of view;

                              This is not the best approach. . .
                                    . . . surely . . .
                                    . . . just not sure what it is!

                              This is the way I decided to go. . .

                              And it is working (so far!)




             Alberto Sim˜es
                        o      Building C/C++ libraries with Perl
Standard Source Packaging




                             Perl modules are not a problem.

                             C/C++ libraries or apps are usually:
                                   bundled with a autoconf script;
                                   bundled with a cmake;




                  Alberto Sim˜es
                             o     Building C/C++ libraries with Perl
AutoTools


                       The autotools are the most used, but:
                             not portable (check Windows);
                             a mess:
                             Perl script that processes a DSL that
                             includes references to M4 macros,
                             and Shell snippets, and generate a
                             shell script. It also interpolates
                             makefiles, and other crazy stuff.

                       Most macros are copy & paste from
                       other projects

                       Few people really understand them



            Alberto Sim˜es
                       o     Building C/C++ libraries with Perl
AutoTools Dependencies

     To use AutoTools we need:
         AutoConf;
         AutoMake;
         LibTool;
         Perl;
         shell;
     I know end-users should only require sh. Is that really true?




                       Alberto Sim˜es
                                  o     Building C/C++ libraries with Perl
Hey, u said Perl?
Use Perl as a Build System


                              Use Perl as a Build System.
                              What are the (my) options?
                                         ExtUtils::MakeMaker;
                                         Module::Build;

      ExtUtils::MakeMaker is not suitable:
          Constructing a Makefile string is error prone;
          Most system detection needs to be defined at configure time;
      Module::Build is easy to subclass:
          Gives all the power of Perl (that can be bad);
          Easier to develop and debug.




                        Alberto Sim˜es
                                   o        Building C/C++ libraries with Perl
Use Perl as a Build System


                              Use Perl as a Build System.
                              What are the (my) options?
                                         ExtUtils::MakeMaker;
                                         Module::Build;

      ExtUtils::MakeMaker is not suitable:
          Constructing a Makefile string is error prone;
          Most system detection needs to be defined at configure time;
      Module::Build is easy to subclass:
          Gives all the power of Perl (that can be bad);
          Easier to develop and debug.




                        Alberto Sim˜es
                                   o        Building C/C++ libraries with Perl
What more do I need?

                   ExtUtils::CBuilder
                   Something that helps compiling C/C++ code
                   ExtUtils::ParseXS
                   Something that helps me parse XS files
                   ExtUtils::Mkbootstrap
                   Something to create DynaLoader bootstrap
                   files
                   ExtUtils::PkgConfig or PkgConfig
                   Something to detect libs that ship a .pc file
                   Config::AutoConf
                   Something that helps me detecting other
                   libraries. . .
                   ExtUtils::LibBuilder
                   Something that knows how to link a standard
                   library
                  Alberto Sim˜es
                             o     Building C/C++ libraries with Perl
The Nuts and Bolts




                     Alberto Sim˜es
                                o     Building C/C++ libraries with Perl
Case Study 1

  Lingua::Jspell
      A Morphological Analyzer for NLP;
      It is a standard C app based on ispell code;
      It includes Perl bindings (through Open3 atm);
      There is no real reason to bundle the app with the Perl
      module.
  The build chain uses:
      Module::Build;
      ExtUtils::CBuilder;
      ExtUtils::LibBuilder;
      Config::AutoConf;


                          Alberto Sim˜es
                                     o     Building C/C++ libraries with Perl
Case Study 1

  Lingua::Jspell
      A Morphological Analyzer for NLP;
      It is a standard C app based on ispell code;
      It includes Perl bindings (through Open3 atm);
      There is no real reason to bundle the app with the Perl
      module.
  The build chain uses:
      Module::Build;
      ExtUtils::CBuilder;
      ExtUtils::LibBuilder;
      Config::AutoConf;


                          Alberto Sim˜es
                                     o     Building C/C++ libraries with Perl
Case Study 1


  Config::AutoConf is used to:


       Detect libraries and headers (in Build.PL):
      §                                                                             ¤
          Config : : AutoConf−>check_header ( ” n c u r s e s . h ” ) ;
          Config : : AutoConf−>check_lib ( ” n c u r s e s ” , ”t g o t o ” ) ;
      ¦                                                                             ¥




  More details on the Build.PL script in the article.



                              Alberto Sim˜es
                                         o     Building C/C++ libraries with Perl
Case Study 1
  I subclass Builder redefining methods:
 §                                                                                     ¤
  sub ACTION_code {
    my $self = s h i f t ;

      # c r e a t e t h e L i b B u i l d e r o b j e c t and c a c h e i t
      $self−>notes ( libbuilder => ExtUtils : : LibBuilder−>new ) ;

      # d i s p a t c h e v e r y needed a c t i o n
      $self−>dispatch ( ” c r e a t e b l i b f o l d e r s ” ) ;
      $self−>dispatch ( ”c r e a t e m a n p a g e s ” ) ;
      $self−>dispatch ( ” c r e a t e y a c c ” ) ;
      $self−>dispatch ( ” c r e a t e o b j e c t s ” ) ;
      $self−>dispatch ( ” c r e a t e l i b r a r y ” ) ;
      $self−>dispatch ( ” c r e a t e b i n a r i e s ” ) ;

      # and now , c a l l s u p e r c l a s s .
      $self−>SUPER : : ACTION_code ;
  }
 ¦                                                                                     ¥

                               Alberto Sim˜es
                                          o       Building C/C++ libraries with Perl
Case Study 1

  The create yacc action also uses Config::AutoConf
 §                                                                                    ¤
  sub ACTION_create_yacc {
    my $self = s h i f t ;

      my $ytabc = ’ s r c / y . t a b . c ’ ;
      my $parsey = ’ s r c / p a r s e . y ’ ;

      r e t u r n i f $self−>up_to_date ( $parsey , $ytabc ) ;

      my $yacc = Config : : AutoConf−>check_prog ( ”y a c c ” ,
                                                   ”b i s o n ” ) ;
      i f ( $yacc ) {
         ‘ $yacc −o $ytabc $parsey ‘ ;
      }
  }
 ¦                                                                                    ¥



                               Alberto Sim˜es
                                          o      Building C/C++ libraries with Perl
Case Study 1
  Build object files (plain ExtUtils::CBuilder usage):
 §                                                                               ¤
  sub ACTION_create_objects {
    my $self = s h i f t ;

      my $cbuilder = $self−>cbuilder ;
      my $c_files = $self−>rscan_dir ( ’ s r c ’ , qr /  . c$ / ) ;
      my $xtr_comp_flags = ”−g ” . $self−>notes ( ’ c c u r s e s ’ ) ;

      f o r my $file ( @$c_files ) {
           my $object = $file =˜ s /  . c / . o/r ;
           n e x t i f $self−>up_to_date ( $file , $object ) ;

          $cbuilder−>compile ( object_file => $object ,
                               source       => $file ,
                               include_dirs => [ ” s r c ” ] ,
                               extra_compiler_flags =>
                                        $xtr_comp_flags ) ;
      }
  }
 ¦                                                                               ¥
                           Alberto Sim˜es
                                      o     Building C/C++ libraries with Perl
Case Study 1
  And the main stuff, build a standard library
 §                                                                                 ¤
  sub ACTION_create_library {
    my $self = s h i f t ;
    my $libbuilder = $self−>notes ( ’ l i b b u i l d e r ’ ) ;
    ...
    # d e f i n e the l i n k e r f l a g s
    my $xlinkerflags = $self−>notes ( ’ l c u r s e s ’ )
                              . $self−>notes ( ’ c c u r s e s ’ ) ;
    i f ( $ˆO =˜ / darwin / ) {
       $xlinkerflags .= ” − i n s t a l l n a m e $ l i b p a t h ” }

     # l i n k i f t h e l i b r a r y i s n o t up t o d a t e
     i f ( ! $self−>up_to_date (  @objs , $libfile ) ) {
        $libbuilder−>l i n k ( module_name => ’ l i b j s p e l l ’ ,
                       extra_linker_flags => $xlinkerflags ,
                       objects =>  @objects ,
                       lib_file => $libfile ) ;
     }
     ...
 ¦                                                                                 ¥
                             Alberto Sim˜es
                                        o     Building C/C++ libraries with Perl
Case Study 1
  And build the C binaries.
 §                                                                                         ¤
     sub ACTION_create_binaries {
       my $self = s h i f t ;
       my $libbuilder = $self−>notes ( ’ l i b b u i l d e r ’ ) ;
       ...
       # define flags
       my $extralinkerflags = $self−>notes ( ’ l c u r s e s ’ )
                                   . $self−>notes ( ’ c c u r s e s ’ ) ;
       ...
       # i f needed , l i n k t h e e x e c u t a b l e
       i f ( ! $self−>up_to_date ( $object , $exe_file ) ) {
             $libbuilder−>link_executable (
                  exe_file => $exe_file ,
                  objects => [ $object ] ,
                  extra_linker_flags =>
                       ”−L s r c − l j s p e l l $ e x t r a l i n k e r f l a g s ” ) ;
       }
       ...
 ¦                                                                                         ¥

                                Alberto Sim˜es
                                           o     Building C/C++ libraries with Perl
Case Study 1
  Work out a testing environment.
 §                                                                                      ¤
  sub ACTION_test {
    my $self = s h i f t ;

      i f ( $ˆO =˜ / mswin32 /i ) {
          $ENV { PATH } = $self−>blib . ”/ u s r l i b ; $ENV{PATH} ” ;
      }
      e l s i f ( $ˆO =˜ / darwin /i ) {
          $ENV { DYLD_LIBRARY_PATH } = $self−>blib . ”/ u s r l i b ” ;
      }
      e l s i f ( $ˆO =˜/linux | bsd | sun | sol | dragon | hpux | irix /i ) {
          $ENV { LD_LIBRARY_PATH } = $self−>blib . ”/ u s r l i b ” ;
      }
      e l s i f ( $ˆO =˜ / aix /i ) {
         my $oldlibpath = $ENV { LIBPATH } | | ’ / l i b : / u s r / l i b ’ ;
          $ENV { LIBPATH } = $self−>blib . ”/ u s r l i b : $ o l d l i b p a t h ” ;
      }
      $self−>SUPER : : ACTION_test
  }
 ¦                                                                                      ¥
                               Alberto Sim˜es
                                          o     Building C/C++ libraries with Perl
Case Study 2

  Lingua::Identify::CLD
      Interface to Google’s Compact Language Detector;
      It bundles a standard C++ library;
      It includes Perl bindings (through XS);
  The build chain uses:
      Module::Build;
      ExtUtils::CBuilder;
      ExtUtils::LibBuilder;
      Config::AutoConf;
      ExtUtils::ParseXS;
      ExtUtils::Mkbootstrap;


                          Alberto Sim˜es
                                     o     Building C/C++ libraries with Perl
Case Study 2

  Lingua::Identify::CLD
      Interface to Google’s Compact Language Detector;
      It bundles a standard C++ library;
      It includes Perl bindings (through XS);
  The build chain uses:
      Module::Build;
      ExtUtils::CBuilder;
      ExtUtils::LibBuilder;
      Config::AutoConf;
      ExtUtils::ParseXS;
      ExtUtils::Mkbootstrap;


                          Alberto Sim˜es
                                     o     Building C/C++ libraries with Perl
Case Study 2
  Compiling XS code as... standard XS code (mostly)
 §                                                                                          ¤
  sub ACTION_compile_xscode {
    ...
    # c r e a t e CLD . c c from CLD . x s
    ExtUtils : : ParseXS : : process_file ( . . . ) ;

     # c r e a t e CLD . o from CLD . c c
     $cbuilder−>compile ( . . . ) ;

     # C r e a t e . b s b o o t s t r a p f i l e , n e e d e d by D y n a l o a d e r .
     ExtUtils : : Mkbootstrap : : Mkbootstrap ( . . . ) ;

     # set linker flags
     my $xlinkerflags = ”−L c l d −s r c − l c l d − l s t d c++” ;
     $xlinkerflags .= ” − l g c c s ” i f $ˆO eq ’ n e t b s d ’ ;

     # link
     $cbuilder−>l i n k ( . . . ) ;
 ¦                                                                                          ¥

                                 Alberto Sim˜es
                                            o      Building C/C++ libraries with Perl
Concluding




     It works!
     The process is similar for all modules;
     Then, this can be generalized in a module;
     Works on UNIX systems;
     Works on Strawberry Win32;




                       Alberto Sim˜es
                                  o     Building C/C++ libraries with Perl
Thank you!




             Alberto Sim˜es
                        o     Building C/C++ libraries with Perl

Weitere ähnliche Inhalte

Was ist angesagt?

DEF CON 27 - workshop - DINO COVOTSOS - hack to basics
DEF CON 27 - workshop - DINO COVOTSOS - hack to basicsDEF CON 27 - workshop - DINO COVOTSOS - hack to basics
DEF CON 27 - workshop - DINO COVOTSOS - hack to basicsFelipe Prado
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplosvinibaggio
 
Bug fix sharing : where does bug come from
Bug fix sharing : where does bug come fromBug fix sharing : where does bug come from
Bug fix sharing : where does bug come from宇 申
 
A bridge between php and ruby
A bridge between php and ruby A bridge between php and ruby
A bridge between php and ruby do_aki
 
PVS-Studio: analyzing ReactOS's code
PVS-Studio: analyzing ReactOS's codePVS-Studio: analyzing ReactOS's code
PVS-Studio: analyzing ReactOS's codePVS-Studio
 
ShaREing Is Caring
ShaREing Is CaringShaREing Is Caring
ShaREing Is Caringsporst
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Alex Balhatchet
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experimentAmos Wenger
 
Safer JS Codebases with Flow
Safer JS Codebases with FlowSafer JS Codebases with Flow
Safer JS Codebases with FlowValentin Agachi
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
Command Line Applications with Ruby
Command Line Applications with RubyCommand Line Applications with Ruby
Command Line Applications with RubyAlexander Merkulov
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects Andrey Karpov
 
Journey of a C# developer into Javascript
Journey of a C# developer into JavascriptJourney of a C# developer into Javascript
Journey of a C# developer into JavascriptMassimo Franciosa
 
Connecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with EmbindConnecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with EmbindChad Austin
 

Was ist angesagt? (19)

In Vogue Dynamic
In Vogue DynamicIn Vogue Dynamic
In Vogue Dynamic
 
DEF CON 27 - workshop - DINO COVOTSOS - hack to basics
DEF CON 27 - workshop - DINO COVOTSOS - hack to basicsDEF CON 27 - workshop - DINO COVOTSOS - hack to basics
DEF CON 27 - workshop - DINO COVOTSOS - hack to basics
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplos
 
PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
Bug fix sharing : where does bug come from
Bug fix sharing : where does bug come fromBug fix sharing : where does bug come from
Bug fix sharing : where does bug come from
 
A bridge between php and ruby
A bridge between php and ruby A bridge between php and ruby
A bridge between php and ruby
 
PVS-Studio: analyzing ReactOS's code
PVS-Studio: analyzing ReactOS's codePVS-Studio: analyzing ReactOS's code
PVS-Studio: analyzing ReactOS's code
 
ShaREing Is Caring
ShaREing Is CaringShaREing Is Caring
ShaREing Is Caring
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
Safer JS Codebases with Flow
Safer JS Codebases with FlowSafer JS Codebases with Flow
Safer JS Codebases with Flow
 
Um2010
Um2010Um2010
Um2010
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
 
Java vs. C/C++
Java vs. C/C++Java vs. C/C++
Java vs. C/C++
 
Command Line Applications with Ruby
Command Line Applications with RubyCommand Line Applications with Ruby
Command Line Applications with Ruby
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
 
Journey of a C# developer into Javascript
Journey of a C# developer into JavascriptJourney of a C# developer into Javascript
Journey of a C# developer into Javascript
 
Connecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with EmbindConnecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with Embind
 
March2004-CPerlRun
March2004-CPerlRunMarch2004-CPerlRun
March2004-CPerlRun
 

Ähnlich wie Building C and C++ libraries with Perl

Makefile for python projects
Makefile for python projectsMakefile for python projects
Makefile for python projectsMpho Mphego
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneDavid Glick
 
Compiler design notes phases of compiler
Compiler design notes phases of compilerCompiler design notes phases of compiler
Compiler design notes phases of compilerovidlivi91
 
please use only these Part 1 Organize the code 85 Fo.pdf
please use only these   Part 1 Organize the code 85  Fo.pdfplease use only these   Part 1 Organize the code 85  Fo.pdf
please use only these Part 1 Organize the code 85 Fo.pdfableelectronics
 
Writing a Gem with native extensions
Writing a Gem with native extensionsWriting a Gem with native extensions
Writing a Gem with native extensionsTristan Penman
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVMJung Kim
 
CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013Spyros Ioakeimidis
 
Raising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityRaising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityThomas Moulard
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone CivettaCocoaHeads France
 
The End of the world as we know it - AKA your last NullPointerException $1B b...
The End of the world as we know it - AKA your last NullPointerException $1B b...The End of the world as we know it - AKA your last NullPointerException $1B b...
The End of the world as we know it - AKA your last NullPointerException $1B b...Michael Vorburger
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfAnassElHousni
 
Working with NIM - By Jordan Hrycaj
Working with NIM - By Jordan HrycajWorking with NIM - By Jordan Hrycaj
Working with NIM - By Jordan Hrycajcamsec
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNoSuchCon
 

Ähnlich wie Building C and C++ libraries with Perl (20)

Makefile for python projects
Makefile for python projectsMakefile for python projects
Makefile for python projects
 
Php on Windows
Php on WindowsPhp on Windows
Php on Windows
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
 
C# tutorial
C# tutorialC# tutorial
C# tutorial
 
Compiler design notes phases of compiler
Compiler design notes phases of compilerCompiler design notes phases of compiler
Compiler design notes phases of compiler
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
 
please use only these Part 1 Organize the code 85 Fo.pdf
please use only these   Part 1 Organize the code 85  Fo.pdfplease use only these   Part 1 Organize the code 85  Fo.pdf
please use only these Part 1 Organize the code 85 Fo.pdf
 
Writing a Gem with native extensions
Writing a Gem with native extensionsWriting a Gem with native extensions
Writing a Gem with native extensions
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013
 
Intro to .NET and Core C#
Intro to .NET and Core C#Intro to .NET and Core C#
Intro to .NET and Core C#
 
Raising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityRaising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code Quality
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
 
.NET for hackers
.NET for hackers.NET for hackers
.NET for hackers
 
The End of the world as we know it - AKA your last NullPointerException $1B b...
The End of the world as we know it - AKA your last NullPointerException $1B b...The End of the world as we know it - AKA your last NullPointerException $1B b...
The End of the world as we know it - AKA your last NullPointerException $1B b...
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
Working with NIM - By Jordan Hrycaj
Working with NIM - By Jordan HrycajWorking with NIM - By Jordan Hrycaj
Working with NIM - By Jordan Hrycaj
 
C++ Training
C++ TrainingC++ Training
C++ Training
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 

Mehr von Alberto Simões

Language Identification: A neural network approach
Language Identification: A neural network approachLanguage Identification: A neural network approach
Language Identification: A neural network approachAlberto Simões
 
Making the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionaryMaking the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionaryAlberto Simões
 
Dictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry TranslationDictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry TranslationAlberto Simões
 
EMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized DictionariesEMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized DictionariesAlberto Simões
 
Aula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de SequênciaAula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de SequênciaAlberto Simões
 
Aula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de AtividadeAula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de AtividadeAlberto Simões
 
Aula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de RequisitosAula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de RequisitosAlberto Simões
 
Aula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de InformaçãoAula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de InformaçãoAlberto Simões
 
Processing XML: a rewriting system approach
Processing XML: a rewriting system approachProcessing XML: a rewriting system approach
Processing XML: a rewriting system approachAlberto Simões
 
Arquitecturas de Tradução Automática
Arquitecturas de Tradução AutomáticaArquitecturas de Tradução Automática
Arquitecturas de Tradução AutomáticaAlberto Simões
 
Extracção de Recursos para Tradução Automática
Extracção de Recursos para Tradução AutomáticaExtracção de Recursos para Tradução Automática
Extracção de Recursos para Tradução AutomáticaAlberto Simões
 

Mehr von Alberto Simões (20)

Source Code Quality
Source Code QualitySource Code Quality
Source Code Quality
 
Language Identification: A neural network approach
Language Identification: A neural network approachLanguage Identification: A neural network approach
Language Identification: A neural network approach
 
Google Maps JS API
Google Maps JS APIGoogle Maps JS API
Google Maps JS API
 
Making the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionaryMaking the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionary
 
Dictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry TranslationDictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry Translation
 
EMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized DictionariesEMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized Dictionaries
 
Modelação de Dados
Modelação de DadosModelação de Dados
Modelação de Dados
 
Aula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de SequênciaAula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de Sequência
 
Aula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de AtividadeAula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de Atividade
 
Aula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de RequisitosAula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de Requisitos
 
Aula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de InformaçãoAula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de Informação
 
PLN em Perl
PLN em PerlPLN em Perl
PLN em Perl
 
Classification Systems
Classification SystemsClassification Systems
Classification Systems
 
Redes de Pert
Redes de PertRedes de Pert
Redes de Pert
 
Dancing Tutorial
Dancing TutorialDancing Tutorial
Dancing Tutorial
 
Processing XML: a rewriting system approach
Processing XML: a rewriting system approachProcessing XML: a rewriting system approach
Processing XML: a rewriting system approach
 
Sistemas de Numeração
Sistemas de NumeraçãoSistemas de Numeração
Sistemas de Numeração
 
Álgebra de Boole
Álgebra de BooleÁlgebra de Boole
Álgebra de Boole
 
Arquitecturas de Tradução Automática
Arquitecturas de Tradução AutomáticaArquitecturas de Tradução Automática
Arquitecturas de Tradução Automática
 
Extracção de Recursos para Tradução Automática
Extracção de Recursos para Tradução AutomáticaExtracção de Recursos para Tradução Automática
Extracção de Recursos para Tradução Automática
 

Kürzlich hochgeladen

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Kürzlich hochgeladen (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Building C and C++ libraries with Perl

  • 1. Building C/C++ libraries with Perl Alberto Manuel Brand˜o Sim˜es a o ambs@perl.pt YAPC::EU::2012 Alberto Sim˜es o Building C/C++ libraries with Perl
  • 2. Disclaimer This is my point of view; This is not the best approach. . . . . . surely . . . . . . just not sure what it is! This is the way I decided to go. . . And it is working (so far!) Alberto Sim˜es o Building C/C++ libraries with Perl
  • 3. Standard Source Packaging Perl modules are not a problem. C/C++ libraries or apps are usually: bundled with a autoconf script; bundled with a cmake; Alberto Sim˜es o Building C/C++ libraries with Perl
  • 4. AutoTools The autotools are the most used, but: not portable (check Windows); a mess: Perl script that processes a DSL that includes references to M4 macros, and Shell snippets, and generate a shell script. It also interpolates makefiles, and other crazy stuff. Most macros are copy & paste from other projects Few people really understand them Alberto Sim˜es o Building C/C++ libraries with Perl
  • 5. AutoTools Dependencies To use AutoTools we need: AutoConf; AutoMake; LibTool; Perl; shell; I know end-users should only require sh. Is that really true? Alberto Sim˜es o Building C/C++ libraries with Perl
  • 6. Hey, u said Perl?
  • 7. Use Perl as a Build System Use Perl as a Build System. What are the (my) options? ExtUtils::MakeMaker; Module::Build; ExtUtils::MakeMaker is not suitable: Constructing a Makefile string is error prone; Most system detection needs to be defined at configure time; Module::Build is easy to subclass: Gives all the power of Perl (that can be bad); Easier to develop and debug. Alberto Sim˜es o Building C/C++ libraries with Perl
  • 8. Use Perl as a Build System Use Perl as a Build System. What are the (my) options? ExtUtils::MakeMaker; Module::Build; ExtUtils::MakeMaker is not suitable: Constructing a Makefile string is error prone; Most system detection needs to be defined at configure time; Module::Build is easy to subclass: Gives all the power of Perl (that can be bad); Easier to develop and debug. Alberto Sim˜es o Building C/C++ libraries with Perl
  • 9. What more do I need? ExtUtils::CBuilder Something that helps compiling C/C++ code ExtUtils::ParseXS Something that helps me parse XS files ExtUtils::Mkbootstrap Something to create DynaLoader bootstrap files ExtUtils::PkgConfig or PkgConfig Something to detect libs that ship a .pc file Config::AutoConf Something that helps me detecting other libraries. . . ExtUtils::LibBuilder Something that knows how to link a standard library Alberto Sim˜es o Building C/C++ libraries with Perl
  • 10. The Nuts and Bolts Alberto Sim˜es o Building C/C++ libraries with Perl
  • 11. Case Study 1 Lingua::Jspell A Morphological Analyzer for NLP; It is a standard C app based on ispell code; It includes Perl bindings (through Open3 atm); There is no real reason to bundle the app with the Perl module. The build chain uses: Module::Build; ExtUtils::CBuilder; ExtUtils::LibBuilder; Config::AutoConf; Alberto Sim˜es o Building C/C++ libraries with Perl
  • 12. Case Study 1 Lingua::Jspell A Morphological Analyzer for NLP; It is a standard C app based on ispell code; It includes Perl bindings (through Open3 atm); There is no real reason to bundle the app with the Perl module. The build chain uses: Module::Build; ExtUtils::CBuilder; ExtUtils::LibBuilder; Config::AutoConf; Alberto Sim˜es o Building C/C++ libraries with Perl
  • 13. Case Study 1 Config::AutoConf is used to: Detect libraries and headers (in Build.PL): § ¤ Config : : AutoConf−>check_header ( ” n c u r s e s . h ” ) ; Config : : AutoConf−>check_lib ( ” n c u r s e s ” , ”t g o t o ” ) ; ¦ ¥ More details on the Build.PL script in the article. Alberto Sim˜es o Building C/C++ libraries with Perl
  • 14. Case Study 1 I subclass Builder redefining methods: § ¤ sub ACTION_code { my $self = s h i f t ; # c r e a t e t h e L i b B u i l d e r o b j e c t and c a c h e i t $self−>notes ( libbuilder => ExtUtils : : LibBuilder−>new ) ; # d i s p a t c h e v e r y needed a c t i o n $self−>dispatch ( ” c r e a t e b l i b f o l d e r s ” ) ; $self−>dispatch ( ”c r e a t e m a n p a g e s ” ) ; $self−>dispatch ( ” c r e a t e y a c c ” ) ; $self−>dispatch ( ” c r e a t e o b j e c t s ” ) ; $self−>dispatch ( ” c r e a t e l i b r a r y ” ) ; $self−>dispatch ( ” c r e a t e b i n a r i e s ” ) ; # and now , c a l l s u p e r c l a s s . $self−>SUPER : : ACTION_code ; } ¦ ¥ Alberto Sim˜es o Building C/C++ libraries with Perl
  • 15. Case Study 1 The create yacc action also uses Config::AutoConf § ¤ sub ACTION_create_yacc { my $self = s h i f t ; my $ytabc = ’ s r c / y . t a b . c ’ ; my $parsey = ’ s r c / p a r s e . y ’ ; r e t u r n i f $self−>up_to_date ( $parsey , $ytabc ) ; my $yacc = Config : : AutoConf−>check_prog ( ”y a c c ” , ”b i s o n ” ) ; i f ( $yacc ) { ‘ $yacc −o $ytabc $parsey ‘ ; } } ¦ ¥ Alberto Sim˜es o Building C/C++ libraries with Perl
  • 16. Case Study 1 Build object files (plain ExtUtils::CBuilder usage): § ¤ sub ACTION_create_objects { my $self = s h i f t ; my $cbuilder = $self−>cbuilder ; my $c_files = $self−>rscan_dir ( ’ s r c ’ , qr / . c$ / ) ; my $xtr_comp_flags = ”−g ” . $self−>notes ( ’ c c u r s e s ’ ) ; f o r my $file ( @$c_files ) { my $object = $file =˜ s / . c / . o/r ; n e x t i f $self−>up_to_date ( $file , $object ) ; $cbuilder−>compile ( object_file => $object , source => $file , include_dirs => [ ” s r c ” ] , extra_compiler_flags => $xtr_comp_flags ) ; } } ¦ ¥ Alberto Sim˜es o Building C/C++ libraries with Perl
  • 17. Case Study 1 And the main stuff, build a standard library § ¤ sub ACTION_create_library { my $self = s h i f t ; my $libbuilder = $self−>notes ( ’ l i b b u i l d e r ’ ) ; ... # d e f i n e the l i n k e r f l a g s my $xlinkerflags = $self−>notes ( ’ l c u r s e s ’ ) . $self−>notes ( ’ c c u r s e s ’ ) ; i f ( $ˆO =˜ / darwin / ) { $xlinkerflags .= ” − i n s t a l l n a m e $ l i b p a t h ” } # l i n k i f t h e l i b r a r y i s n o t up t o d a t e i f ( ! $self−>up_to_date ( @objs , $libfile ) ) { $libbuilder−>l i n k ( module_name => ’ l i b j s p e l l ’ , extra_linker_flags => $xlinkerflags , objects => @objects , lib_file => $libfile ) ; } ... ¦ ¥ Alberto Sim˜es o Building C/C++ libraries with Perl
  • 18. Case Study 1 And build the C binaries. § ¤ sub ACTION_create_binaries { my $self = s h i f t ; my $libbuilder = $self−>notes ( ’ l i b b u i l d e r ’ ) ; ... # define flags my $extralinkerflags = $self−>notes ( ’ l c u r s e s ’ ) . $self−>notes ( ’ c c u r s e s ’ ) ; ... # i f needed , l i n k t h e e x e c u t a b l e i f ( ! $self−>up_to_date ( $object , $exe_file ) ) { $libbuilder−>link_executable ( exe_file => $exe_file , objects => [ $object ] , extra_linker_flags => ”−L s r c − l j s p e l l $ e x t r a l i n k e r f l a g s ” ) ; } ... ¦ ¥ Alberto Sim˜es o Building C/C++ libraries with Perl
  • 19. Case Study 1 Work out a testing environment. § ¤ sub ACTION_test { my $self = s h i f t ; i f ( $ˆO =˜ / mswin32 /i ) { $ENV { PATH } = $self−>blib . ”/ u s r l i b ; $ENV{PATH} ” ; } e l s i f ( $ˆO =˜ / darwin /i ) { $ENV { DYLD_LIBRARY_PATH } = $self−>blib . ”/ u s r l i b ” ; } e l s i f ( $ˆO =˜/linux | bsd | sun | sol | dragon | hpux | irix /i ) { $ENV { LD_LIBRARY_PATH } = $self−>blib . ”/ u s r l i b ” ; } e l s i f ( $ˆO =˜ / aix /i ) { my $oldlibpath = $ENV { LIBPATH } | | ’ / l i b : / u s r / l i b ’ ; $ENV { LIBPATH } = $self−>blib . ”/ u s r l i b : $ o l d l i b p a t h ” ; } $self−>SUPER : : ACTION_test } ¦ ¥ Alberto Sim˜es o Building C/C++ libraries with Perl
  • 20. Case Study 2 Lingua::Identify::CLD Interface to Google’s Compact Language Detector; It bundles a standard C++ library; It includes Perl bindings (through XS); The build chain uses: Module::Build; ExtUtils::CBuilder; ExtUtils::LibBuilder; Config::AutoConf; ExtUtils::ParseXS; ExtUtils::Mkbootstrap; Alberto Sim˜es o Building C/C++ libraries with Perl
  • 21. Case Study 2 Lingua::Identify::CLD Interface to Google’s Compact Language Detector; It bundles a standard C++ library; It includes Perl bindings (through XS); The build chain uses: Module::Build; ExtUtils::CBuilder; ExtUtils::LibBuilder; Config::AutoConf; ExtUtils::ParseXS; ExtUtils::Mkbootstrap; Alberto Sim˜es o Building C/C++ libraries with Perl
  • 22. Case Study 2 Compiling XS code as... standard XS code (mostly) § ¤ sub ACTION_compile_xscode { ... # c r e a t e CLD . c c from CLD . x s ExtUtils : : ParseXS : : process_file ( . . . ) ; # c r e a t e CLD . o from CLD . c c $cbuilder−>compile ( . . . ) ; # C r e a t e . b s b o o t s t r a p f i l e , n e e d e d by D y n a l o a d e r . ExtUtils : : Mkbootstrap : : Mkbootstrap ( . . . ) ; # set linker flags my $xlinkerflags = ”−L c l d −s r c − l c l d − l s t d c++” ; $xlinkerflags .= ” − l g c c s ” i f $ˆO eq ’ n e t b s d ’ ; # link $cbuilder−>l i n k ( . . . ) ; ¦ ¥ Alberto Sim˜es o Building C/C++ libraries with Perl
  • 23. Concluding It works! The process is similar for all modules; Then, this can be generalized in a module; Works on UNIX systems; Works on Strawberry Win32; Alberto Sim˜es o Building C/C++ libraries with Perl
  • 24. Thank you! Alberto Sim˜es o Building C/C++ libraries with Perl