Examples with ofxGui fails on Linux

Hello everybody, I am checking if some addons that I have written in the past still work and I bumped in this error on linux, I am using the last ubuntu with the last nightly linux version of OF.
The application /examples/gui/guiExample fails to compile with this error.

/home/dapx/Sources/OF/of_v20221204_linux64gcc6_release/addons/ofxGui/src/ofxBaseGui.cpp:104: error: undefined reference to 'ofTrueTypeFont::load(boost::filesystem::path const&, int, bool, bool, bool, float, int)'

I have tried some other examples without the GUI and they works.

Hey @edapx , try adding the -std=c++17 flag to the project. I use Qt Creator so I added it in the .qbs file. I got the same error when I didn’t use the flag.

Hello TimChi, it worked, thanks :wink:

I am not sure but I think this line

Should be

of.cxxFlags: ['-std=c++17']         // flags passed to the c++ compiler

@TimChi what do you think?

Yeah that’s the line and the change looks great! I apologize as I should have posted a fix for it so I’m glad that you did. After playing around a bit yesterday, the flag doesn’t seem necessary when compiling with make. There might be a way to tell Qt Creator to always use c++17.

So, as far as I have understand, the script install_template.sh needed to use qt on linux reads the template file that I have linked before. So modifying that file should modify the qbs file whenever you create or import an OF project with QT.

Modifying the template sounds like a great idea, and seems like it should work. The install_template.sh script looks like it just copies the files to a location where Qt can find them. I wonder if this would be a good pull request too.

Support for c++17 is default in the nightly, but the gcc version (in config.linux.common.mk) also determines how OF is compiled. Maybe the install_template.sh could find the gcc version in a similar way. I think these two lines (141, 142) from config.linux.common.mk get the gcc version:

GCC_MAJOR := $(shell expr `gcc -dumpversion | cut -f1 -d.`)
GCC_MINOR := $(shell expr `gcc -dumpversion | cut -f2 -d.`)

Edit: I wonder if these two lines are platform specific though. gcc -dumpversion | cut -f1 -d. works OK in a terminal on macOS.