Compiling tarray.cpp example with g++

I am trying to test the tarray.cpp example using g++ and not cmake. I do not need the entire hdf5 program to run, just the example. I included all of the dependencies in one folder and ran g++. I need to call the library, butI am not sure which one. For anyone who has compiled hdf5 with g++, what is the correct way of compiling an example? Note this is a repost of a question for the C++ group, but that section appear to not be active recently. Compiling tarray.cpp with g++

Thank you for the help.