Centuries of feudal warfare preceded the unification of Vietnam in 1802. It came with the conquering of Hanoi by Gia Long, who became emperor of the country and founder of the last dynasty.