If you configure and install libsndfile with:
./configure --prefix=$HOME/local
make
make install
you should then set/modify your LD_LIBRARY_PATH variable:
export $LD_LIBRARY_PATH=$HOME/local/lib
and then compile with
g++ -I $HOME/local/include -L $HOME/local/lib -lsndfile testsnd.c -o testsnd