Página 1 de 1

Error en Embedded Perl en C++

NotaPublicado: 2011-09-05 09:41 @445
por Vertik
¡Hola a todos!

Espero que el verano bien :D

Bueno, aquí vuelta al trabajo y ¡me he encontrado con una dificultad! Suerte de vosotros ¡je,je,je!

Esta es:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
Can't load module HTML::Parser, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the HTML::Parser module statically linked into it.)
 at /usr/local/lib/perl/5.10.1/HTML/Entities.pm line 154
Compilation failed in require at /usr/local/lib/perl/5.10.1/HTML/Entities.pm line 154.
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


Estoy lanzando un código Perl (funciona) desde C++ y surge este error. Es como si no supiera linkar este módulo.

¿Alguna sugerencia? :(


Gracias

Re: Error en Embedded Perl en C++

NotaPublicado: 2011-09-05 10:02 @460
por explorer

Re: Error en Embedded Perl en C++

NotaPublicado: 2011-09-06 05:34 @273
por Vertik
¡¡¡Gracias, explorer!!!

Como bien dices, aparece en esa web.

Lo explicare por aquí si os parece bien (por si alguien llega al foro y ve la pregunta). (Nota: mi nivel no es alto, así que seguro que habrá una manera más fácil de hacerlo.)

Lo que he hecho para solucionar el problema es crear el fichero:

xsinit.cpp
Sintáxis: [ Descargar ] [ Ocultar ]
Using cpp Syntax Highlighting
  1. EXTERN_C void
  2. xs_init(pTHX)
  3. {
  4.         char *file = __FILE__;
  5.         dXSUB_SYS;
  6.  
  7.         /* DynaLoader is a special case */
  8.         newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
  9. }
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4


Con su header xsinit.h
Sintáxis: [ Descargar ] [ Ocultar ]
Using cpp Syntax Highlighting
  1. #include <EXTERN.h>
  2. #include <perl.h>
  3.  
  4. EXTERN_C void xs_init (pTHX);
  5.  
  6. EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4


Luego en la llamada para introducir los parámetros necesarios para ejecutar el Perl desde C, se modifica:

perl_parse(my_perl, NULL, argc, my_argv,NULL);

por

perl_parse(my_perl, xs_init, argc, my_argv,NULL);

xs_init() realiza "magia" (indica al intérprete de Perl cómo linkar los ficheros a usar) y el error desaparece y ya puedes usar normalmente el use "Modulo::X".

¡Espero que sea de ayuda a todos!

¡Mil gracias, explorer!