To create the character of Dido, paramour of Aeneas in books 1-4 of his epic Aeneid, Vergil drew upon historical accounts of a Phoenician exile by the same name. The story of this "historical" Dido was recorded by the Greek historian Timaneus of Tauromenium. Marilynn Desmond provides a good summary of it in the academic text Reading Dido:

Dido fled to Libya with a group of followers after her brother, Pygmalion, had killed her husband. When a Libyan king wished to marry her, she refused him; when she was compelled by her people to accept him, she pretended to stage a ceremony in order to release herself from a sacred promise to her husband. She built and lit a large funeral pyre next to her dwelling, and she threw herself into it from her house.
There is another account in Justin's Epitoma, drawn from the work of the Roman historian Trogus, which goes into greater detail, especially in its characterization of this "historical" Dido's wit and resourcefulness.

While Vergil was aware of the tale of this Phoenician when he wrote the Aeneid, the two women cannot be one and the same; there is no way, chronologically, that the date in which the "historical" Dido would have founded Carthage could fit in between the date for the destruction of Troy (where Aeneas came from) was destroyed and the date for the founding of Lavinium (where Aeneas went; according to the Roman historian Livius, Aeneas founded Lavinium, his son Ascanius founded Alba Longa, and at Alba Longa Romulus and Remus were born). If the two had encountered each other, Aeneas would have been centuries old. To reference one of my favorite British sci-fi shows, even if he were still alive, the age difference would have been insurmountable. Therefore, this "historical" Dido never actually met Aeneas-- assuming that he existed at all, and is not merely a mythological construct. By bringing her into his story, Vergil was simply having fun with history, sort of like the anachronisms any good Classics scholar will find in Stanley Kubrick's Spartacus (and don't even get me started on Gladiator!).

My principal source for this writeup was pages 24-6 of Reading Dido: Gender, Textuality and the Medieval AENEID by Marilynn Desmond, published by the University of Minnesota Press in 1994.