use DynaLoader; # declare the library functions @exconfig_syms = ('XS_ExConfig_fnGetLocalIPAddresses'); # declare the library files $ExConfigLibFile='libconf.so'; # load the library file $exconfig_libref = load_shared_lib($ExConfigLibFile); unless (import_shared_lib_syms($exconfig_libref, \@exconfig_syms)) { print ("\n*** ERROR: failed to import symbols from library '$ExConfigLibFile'!"); exit; } { my @locals = split(/\|/, hostIP()); print ("Local address". ((@locals > 1) ? "es" : '').":\n\t" . join ("\n\t", @locals)); } sub load_shared_lib { my $lib_file = shift; my $lib_ref = undef; $lib_ref = DynaLoader::dl_load_file($lib_file,1); return $lib_ref; } sub import_shared_lib_syms { my $lib_ref = shift; my $lib_syms = shift; # Load functions from shared library foreach my $key (@{$lib_syms}) {#Load function from shared library my $sym_ref = DynaLoader::dl_find_symbol($lib_ref, $key); unless ($sym_ref) { print("\nCan't load symbol '$key' from shared library $lib_file:\n\t". DynaLoader::dl_error()); return 0; } # Install XSub function (my $func = $key) =~ s/XS_//; my $func_ref = DynaLoader::dl_install_xsub($func, $sym_ref); unless ($func_ref) { print("\nUnable to install '$key' function from shared library $lib_file:\n\t". DynaLoader::dl_error()); return 0; } } return 1; # $lib_ref; } sub hostIP { my $IPs; # the below functon return the value in 64bit perl # and it returns the 'Segmentation fault' error in 32bit perl ExConfig_fnGetLocalIPAddresses($IPs); return $IPs; }