Trying something as simple as 'use POSIX ();' causes the perl plugin to croak: $ ./src/nbdkit -e foo -fv plugins/perl/.libs/nbdkit-perl-plugin.so \ script=plugins/perl/example.pl nbdkit: debug: registering plugins/perl/.libs/nbdkit-perl-plugin.so nbdkit: debug: registered plugins/perl/.libs/nbdkit-perl-plugin.so (name perl) nbdkit: debug: plugins/perl/.libs/nbdkit-perl-plugin.so: load nbdkit: debug: plugins/perl/.libs/nbdkit-perl-plugin.so: config key=script, value=plugins/perl/example.pl Can't load module Fcntl, dynamic loading not available in this perl. (You may need to build a new perl executable which either supports dynamic loading or has the Fcntl module statically linked into it.) at /usr/lib64/perl5/POSIX.pm line 17. Compilation failed in require at /usr/lib64/perl5/POSIX.pm line 17. BEGIN failed--compilation aborted at /usr/lib64/perl5/POSIX.pm line 17. Compilation failed in require at plugins/perl/example.pl line 2. BEGIN failed--compilation aborted at plugins/perl/example.pl line 2. nbdkit: error: plugins/perl/example.pl: one of the required callbacks 'open', 'get_size' or 'pread' is not defined by this Perl script. nbdkit requires these callbacks. Per 'perldoc perlembed', the solution is simple: statically incorporate the DynaLoader module into the embedded interpreter. Signed-off-by: Eric Blake <eblake@redhat.com> --- plugins/perl/perl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c index ec82ecb..64d9d17 100644 --- a/plugins/perl/perl.c +++ b/plugins/perl/perl.c @@ -140,6 +140,16 @@ check_perl_failure (void) return 0; } + +EXTERN_C void boot_DynaLoader (pTHX_ CV *cv); + +static void +xs_init(pTHX) +{ + char *file = __FILE__; + newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); +} + static int perl_config (const char *key, const char *value) { @@ -158,7 +168,7 @@ perl_config (const char *key, const char *value) /* Load the Perl script. */ argv[1] = (char *) script; - if (perl_parse (my_perl, NULL, argc, argv, NULL) == -1) { + if (perl_parse (my_perl, xs_init, argc, argv, NULL) == -1) { nbdkit_error ("%s: error parsing this script", script); return -1; } -- 2.9.3