Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Separating source files in YAML::XS

by tinita (Parson)
on Apr 27, 2019 at 16:07 UTC ( #1233043=perlquestion: print w/replies, xml ) Need Help??

tinita has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to seperate some *.c/*.h files in YAML::XS. Currently the CPAN distribution looks like this:

In the LibYAML directory there are copied files from the libyaml sources plus the bindings to perl (perl_libyaml.{c,h}).
I'd like to separate the libyaml sources into their own directories to make it easy to remove/ignore them and use the installed system libyaml instead, if one wants to.
Here I put the files into LibYAML/src and LibYAML/include:
The problem is I don't know how to change LibYAML/Makefile.PL.
Currently I'm getting this error because apparently it can't find the yaml.h:

Can't load '.../yaml-libyaml-pm/YAML-LibYAML-0.77/blib/arch/auto/YAML/ +XS/LibYAML/' for module YAML::XS::LibYAML: .../yaml-libyaml-pm/YAML-LibYAML-0.77/blib/ +arch/auto/YAML/XS/LibYAML/ undefined symbol: yaml_sequence_start_event_initialize at .../perl-5.24.1/lib/5.24.1/x86 +_64-linux/ line 193, <CONFIG> line 1. at .../yaml-libyaml-pm/YAML-LibYAML-0.77/blib/lib/YAML/ line 20.
Any ideas/pointers on how to set this up?

To reproduce:
Clone the git repo:
git clone -b seperate-libyaml-source
and go into the directory YAML-LibYAML-0.77:
perl Makefile.PL make make test

Tux was working on it and came up with this:

use ExtUtils::MakeMaker; use strict; use Config; my $s = join " " => sort glob ("*.c"), glob ("src/*.c"), glob ("*.xs" +); (my $o = $s) =~ s{\.(?:c|xs)\b}{$Config::Config{_o}}g; (my $l = $o) =~ s{\bsrc/}{}g; my $DEFINE = $^O eq 'MSWin32' ? '-DHAVE_CONFIG_H -DYAML_DECLARE_EXPORT' : '-DHAVE_CONFIG_H'; WriteMakefile( NAME => 'YAML::XS::LibYAML', ABSTRACT_FROM => 'lib/YAML/XS/', AUTHOR => 'Ingy döt Net <>', PREREQ_PM => {}, CCFLAGS => "-I. -Isrc -Iinclude $DEFINE", OBJECT => $o, LDFROM => $l, );

It's working for me, thanks Tux!
The only weird thing is that it is compiling again whenever one does make test. Does anyone have an idea?

Replies are listed 'Best First'.
Re: Separating source files in YAML::XS
by marto (Cardinal) on Apr 27, 2019 at 20:38 UTC

    Following your instructions I get:

    ./perl_libyaml.h:16:10: fatal error: yaml.h: No such file or directory #include <yaml.h> ^~~~~~~~ compilation terminated.

    Which I get past by adding "INC" => "-I../LibYAML/include/", to the Makefile.PL. The tests then fail with things like:

    # Failed test 'require YAML::XS;Can't load '/home/marto/code/yaml-li +byaml-pm/YAML-LibYAML-0.77/blib/arch/auto/YAML/XS/LibYAML/' + for module YAML::XS::LibYAML: /home/marto/code/yaml-libyaml-pm/YAML- +LibYAML-0.77/blib/arch/auto/YAML/XS/LibYAML/ undefined sym +bol: yaml_sequence_start_event_initialize at /usr/lib/i386-linux-gnu/ +perl/5.26/ line 187

    I'll do some more digging in the morning.

      Oh right, I think I don't get the first error because I have the libyaml package installed, so it's finding the yaml.h from that one instead.

      Tux is actually also working on this...
Re: Separating source files in YAML::XS
by tinita (Parson) on Apr 28, 2019 at 10:09 UTC
    I updated the node. Tux found a way to do it, there's just a weird behavior when doing make test

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1233043]
Approved by Perlbotics
Front-paged by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2021-01-22 04:50 GMT
Find Nodes?
    Voting Booth?