France's ambassador to Burkina Faso, Xavier Lapdecab, urged people via Twitter to act with "absolute precaution" as the attack is ongoing.
A government statement says four assailants have been "neturalised" in the unfolding attack in Burkina Faso's capital.
Sawadogo said the G5 meeting was supposed to have been held at the headquarters but had been moved to another room.
As a retired soldier who came to power in a military coup, Compaore had been involved in trade-offs with armed elements to stave off any chance for the kind of attacks being witnessed in Burkina Faso over the past two years.
French President Emmanuel Macron spoke with President Roch Marc Christian Kabore to express his condolences and support, and also to thank the country's forces for their quick intervention.
But some people have started calling it a terrorist attack.
One of the militants' assaults destroyed a room in the army headquarters where senior officers were to have met but was relocated at the last minute, according to Security Minister Clement Sawadogo.
An interim United Nations report seen by AFP warned of a "growing threat" to the Sahel from two groups: the Islamic State in the Great Sahara (ISGS) and Ansar al-Islam.
Former NBA agent Dan Fegan killed in vehicle crash
Fegan had represented many National Basketball Association players, including John Wall , Demarcus Cousins and Dwight Howard . The Colorado State Patrol said the SUV was trying to cross or merge onto Highway 82 when it was broadsided by the RFTA bus.
Five emergency centers were set up in hospitals, a military barracks and at a stadium in Ouagadougou to treat the casualties, said Col. Amade Kafando, director general of Burkina Faso's army health department.
The insurgency has caused thousands of deaths, prompted tens of thousands to flee their homes and dealt crippling blows to economies that are already among the poorest in the world.
But gunfire erupted again later in the day at the country's military headquarters in western Ouagadougou, where the other attackers were killed.
No group has claimed responsibility although suspicion will fall on a disparate group of Islamist movement active in the West African region. No one has so far claimed responsibility for that attack.
The US embassy in the city has advised people to seek shelter.
Various reports suggest that four attackers have been killed at the French embassy and three have been killed at the army headquarters.
Five countries - Burkina Faso, Niger, Chad, Mali and Mauritania - launched a new task force a year ago to tackle Islamist militants in the arid Sahel region, to which global donors have committed $500 million US. Twelve French soldiers have died since the campaign - called Operation Barkhane - was launched in August 2014.