in reply to Inline C, accessing an so lib

The obvious thing to check is that the $LD_LIBRAY_PATH is set when your script runs. Try printing the value of

$ENV{"LD_LIBRARY_PATH"}

From the script. If it doesn't have the right directory the library won't be found