Barack Obama might be out of the White House, but he just can't quit his pal, Prime Minister Justin Trudeau.

Barack and Canada's big cheese grabbed dinner at the Liverpool House Tuesday in Montreal ... on the heels of Prez 44's speech blasting President Trump for pulling out of the Paris Climate Accord.

Both guys rolled up their sleeves to talk shop ... namely, how to foster a new generation of leaders in their respective countries. Let's face it -- doesn't hurt to look like these guys either.

The rock star treatment they got outside the restaurant proves it.