Products > Embedded Computing

Graphical library for Raspberry in C / C ++

(1/4) > >>

I need to develop an application in C / C ++ with a graphical environment for Raspberry, something similar to a video game (although it is not a video game). I have to handle videos with audio, images, texts with artistic fonts, etc.

I used QT / QTCreator years ago, but I think it is currently a commercial product, with some very limited free version, so then I prefer not to use it. Searching for Google, I find SFML, GTK+ and WxWidgets, I think that all three could be installed and used on CodeBlocks.

And for now I haven't found anything else that can be used with C / C ++.
Any suggestions or advice on free environments for graphical development with Raspberry, using C or C ++?


Nominal Animal:
Qt is dual-licensed.  Just choose community edition at the site, so you get the LGPL/GPL-licensed stuff.  Or use the distribution-provided development packages.  AFAIK, all of the commonly used Qt5 modules are dual-licensed, including Qt Creator, network (built-in browser support) and multimedia; see e.g. here.

Qt5 is object-oriented, so you'll want to use either C++ or something like Python3 for the UI.

GTK+ is LGPL-licensed, and written in C.

Both Qt and GTK+ are extensively used in Linux distributions: Qt in KDE, and GTK+ for most other desktop environments.  Some, like XFCE and LXDE, incorporate support for both.

There is also Qt Embedded, so you can run Qt applications under EGL (using the OpenGL drivers provided for Raspberry Pi) without X11, as a full-screen application without any desktop environment at all.  However, I do believe you'd need to compile the support libraries yourself from the (GPL/LGPL) sources: not that big of a deal, but you'd need to compile the libraries first, then test some of the examples to verify it works.

Assuming the application is intended to be a fullscreen one, without any desktop environment at all, only this one application running in the user interface, I'd definitely use Qt 5 Embedded.

I personally like to construct the Qt UI in Python3 instead of C++, because that way the end users can modify/update the UI themselves.  However, for a full-screen single-application case, I don't think it is as important, so in this particular case, I'd recommend C++ and Qt5 Embedded on EGL (OpenGL ES).


Thanks, I think I will try QT again, but I will also try GTK + as an alternative.

The problem is that the product I need to design will be commercial, so a free license, like QT's, requires that I give my development sources so that are freely accessible to anyone, and I can't do that.

Do you know anything about SFML and WxWigdets?

Nominal Animal:

--- Quote from: luiHS on September 09, 2021, 01:43:02 am ---The problem is that the product I need to design will be commercial, so a free license, like QT's, requires that I give my development sources so that are freely accessible to anyone, and I can't do that.
--- End quote ---
No.  You can create a closed-source proprietary binary that links to LGPL libraries at run time.  See e.g. here.  You only need to provide the sources to those libraries (and only if you distribute them along with your program), not your own application.
See here for a summary of the Qt 5 modules and their licensing.

In particular, you do not need to provide sources to your application that only links at run time to the LGPL libraries.  (Run time dynamic linking is the default, too.)
That is the key difference between GPL and LGPL: LGPL expressly clarifies that linking to a LGPL-licensed library does not create a derivative in the copyright law sense, and does not extend the LGPL license to the application linking to such a library.

--- Quote from: luiHS on September 09, 2021, 01:43:02 am ---Do you know anything about SFML and WxWigdets?
--- End quote ---
Only enough to say I find Qt and GTK+ much more powerful for development on Linux.

In practice, you should consider building your application so that it runs as a dedicated user account (because it sounds like a full-screen appliance of some sort).  Depending on how you intend to distribute it –– as a package, or as a dedicated distribution on a provided 'Pi ––, you only need to provide sources of the open source packages (including the Qt libraries) used to build the environment; just make sure your binaries are dynamically linked (do not use -static compiler option!) to LGPL or similarly licensed libraries.

Linking to the standard C and C++ libraries does not create a derivative of those, nor does using Linux syscalls.

If you provide it as a package, compile your application using -Wl,-rpath,'$ORIGIN/../lib' as described in man 8 ld-linux, so that if your application is stored at /usr/lib/yourapp/bin/executable, the default location for dynamic libraries is /usr/lib/yourapp/lib/ (or, to be precise, ../lib/ relative to the location of the binary).  This way you can provide the specific versions of the Qt libraries (and whatever other libraries your application requires) and C++ runtime there, and use the system default standard C library.  This yields a very portable way of creating proprietary binaries that work on many Linux distributions.

C or C++? You'll need to make a choice. There's nothing like C/C++, even though that keeps being mentioned everywhere. Oh well, that's probably never going to sink in.

So depending on the language, you'll have access to different libraries. QT is C++ of course, and using it from C, although probably possible with the right interface, would probably make no sense, and would be a lot of extra work. So with QT, of course, you'll have to use C++

Now QT embedded was mentioned not long ago, and AFAIK, it now requires a commercial license. So QT embedded is out, unless you're ready to get a license.

GTK is indeed another option. Contrary to QT, it can be used both from C and C++, there's official bindings for C++ (gtkmm).

In both cases, you mentioned playing videos, and I don't think there is any video support in QT, but I may be mistaken as I haven't used it in ages. In which case you'd have to use yet another third-party library. For GTK, I think a video widget has been introduced in GTK4, so that would probably be an easy path. Graphics are done using Cairo on GTK - you can take a look. Cairo allows pretty antialised graphics and font rendering.

In any case, I suppose you'll be using Linux on the RPi?

One option, from your description, would also be to use some sort of "game engine". There are quite a few out there, and many will get you game-like UIs pretty easily. You could consider Allegro, OGRE...


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version