He was born in Brechin, Scotland, came to the United States in 1843, and was brought up in Cincinnati. He graduated second in the class of 1863 at West Point and entered the engineer corps. During the Civil War, he served in the campaign of 1864 against Richmond, Virginia; was chief engineer of General Benjamin Butler's Army of the James during the construction of the Dutch Gap Canal; and was at the head of all engineering operations of the left column at Hatcher's Run and in the pursuit of General Robert E. Lee's army.