Embed perl in C question
I've an application, which is made up of quite a number of shared libraries. I've written perl extensions to some of them. Also, I've embedded perl into the application.
I'm calling a perl script from with in C++. Lets say, my perl extensions are named as SV::Net::Info and SV::Interface and my perl file is looking like this
use SV::Net::Info;
use SV::Interface;
#use IO::Socket;
...
...
...
I'm able to read the perl script from C++ and send the output back to C++ without any issues. Problems arise when I uncomment the third line, use IO::Socket;
I'm getting error message saying that
Can't load module IO, dynamic loading not available in this perl.
(You may need to build a new perl executable which either supports
dynamic loading or has the IO module statically linked into it.)
This is because IO itself is a C library. I've added the xs-glue as mentioned here. It didn't solve my problem as the added glue is looking for boot_IO symbol (which is defined in IO.so file). I cannot link my application with IO.so as it is a file, which perl opens at runtime, using dlopen. (Also, my application should work on windows, and window开发者_高级运维s provides only .dll file and not .lib file). What is the way out ?
I'm thinking of writing a wrapper function boot_IO which runs the actual boot_IO function from IO.so at runtime using dlopen. Is this the only option ?
It sounds like you need to statically link IO::Socket
's library, and, since no .a
file is created, that looks like it is impossible. Can you change your code to use the built-in socket functions?
Another option would be to create a pure Perl implementation of IO::Socket
.
精彩评论