Fixed: openFrameworks in Qt Creator, unrecognized command line option ‘–std=gnu++14’

Another episode in the « openFrameworks doesn’t work out-of-the-box » series

openFrameworks

Now that I managed to get rid of my library linking problems from last time, I tried to use oepnFrameworks in one of the best IDEs for C++ out there at the moment: Qt Creator.

However as soon as as I tried to compile a random example project I stumbled on a compile error:

[cc lang= »bash »]

error : error: unrecognized command line option ‘–std=gnu++14’

[/cc]

I soon found out that it was a very specific problem with the version of GCC I currently have on my Ubuntu 14.04 LTS: the 4.8.4 one. As a matter of fact, this GCC is too old and doesn’t know yet of the –std=gnu++14 compile option. As the answer on this SO question suggests, the solution with this GCC version is to use the –std=c++1y flag instead.

But wait ! Where was this flag added in the first place ? The most surprising part of it all was that if I tried to manually make the example OF projects in the terminal, it would compile just fine. The problem only arose when trying to compile within QtCreator.

So where was this pesky compile flag passed to the compiler ? Simple: in the .qbs file OpenFrameworks automatically creates when you run and install their bundled QtCreator plugin script !

I didn’t know the exact location of that file so what I did (but there may be a simpler solution, I think you can get to it in QtCreator directly) was putting myself in the openFrameworks installation directory and run a braindead grep search :

[cc lang= »bash »]

baron_a@Mothership openFrameworks090 $ grep -Rni « gnu++14 » .
./libs/openFrameworksCompiled/project/qtcreator/modules/of/of.qbs:434: .concat([‘-Wno-unused-parameter’,’-std=gnu++14′])

[/cc]

Indeed, the flag was hard-coded into the .qbs ! And then, manually replacing « gnu++14 » by « c++1y » did the trick, and I finally was able to compile and run Openframeworks projects in Qt Creator.

I’m starting to think it’s a shame to stumble on so much problems when trying to kickstart yourself into OF (given that I already know it pretty well from previous experiences) on such a general audience distro like an Ubuntu LTS (which is supposed to be extra reliable). Hadn’t I already known it, I may have simply thrown it all away, declaring that this whole mess just doesn’t work.

Anyway that’s fixed now.

Une réflexion sur « Fixed: openFrameworks in Qt Creator, unrecognized command line option ‘–std=gnu++14’ »

Répondre à greg Annuler la réponse

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *