I have had the same problem. It seems that you need to configure the make option with a file. Create a file, ~/.R/Makevars, and insert "LDFLAGS=-L/share/apps/HDF5/lib" (in your case) into it. It solved my problem.