You have to compute the distance between P and all the other points, then take the min. That was the obvious part.
The difficult part is to compute the distance between two gps coordinate. GPS use the WGS84 geodesic system to represent points on earth.
There is also different ways to compute a distance on a ~sphere (loxodromic distance and great circle distance are the main ones).
Euclidian distance is always false on a sphere (not even close) because at non-zero latitude, 1°Lat < 1°Lon...
See Distance using WGS84-ellipsoid for the computation by yourself, or GDAL if you accept a lib which will do it for you.
You can use GDAL to convert points representations in others geodesic systems. You can for instance project points on a plan geodesic system, then use (x,y,z) coordinates, then compute distances (or better: squared distance = x²+y²+z²).
I think the google map api provide an easy to use distance methode for gps coordinate, if by chance your already using it.