Most of the time, when you compile a shared library, executing it is meaningless and doing so produces nothing useful:
$ ./libfoobarbaz.so Segmentation fault
There is a howto about this subject here. The principle is to define an entry point in the library and populate the interp section of the ELF file with the interpreter's pathname (e.g. /lib/ld-linux.so.2).