sudo apt-get install libproj-dev

To get distance traveled in meters you can convert latitude and longitude to UTM coordinates, where UTM coordinates are measured in meters. That conversion is very easy when using libproj. If you want to use latitude and longitude look for great circle equations.