Since you did not show any errors you are getting, I assume you have installed all the necessary dependancies.
Here is a working version of that same triangles.cpp code taken from SO answer to...