LinuxCollections.com's Blog
Introduction to GUI Development
written November 1, 2024 by Time Traveler
Category: BlogEntry Tags: Introduction to GUI Development; Development; Graphical User Interface; #56
We have released a video giving an overview to developing several examples in the Graphical User Interface. For those that just want the zip, we will continue the overview below…
You can download the zip file here:
intro_gui_dev.zip
The video walks through setting up a development system, an overview of basic development concepts, and goes through 3 Graphical User Interface approaches - Xlib (X-windows), GTK, and Wayland. Each example shows how to get a window on the screen, and the fully commented source code is in the zip file. We point out that there was only 1 example ever written, which gets a window on the screen, and then everything else is built from that template. The zip file has those templates for X, GTK, and Wayland. The README.TXT from the zip is included below for reference, and the video link follows.
LinuxCollections.com How To Video - Introduction to GUI Development
File: README.txt
Files used in examples/video:
mountoptiso.sh,
build, hello.c,
buildx, hellox.c,
buildgtk, helloworldgtk.c,
buildwayland, hellowayland.c, xdg-shell-protocol.c
Introduction to GUI Development
(the Graphical User Interface)
To begin with, we are going to start with a very basic C program, to lay the groundwork for
development, and cover some very basic "getting started" foundational items.
We will be using our Debian USB Developer Collection from LinuxCollections.com
All references will be on the Debian system and using the apt system (apt-get) to
install development tools, libraries, and header files.
We will indicate command line text by ending with "[Enter]"
Script code will be separated with ################## lines
Source code will be separated the /*********************/ lines
To start with, we use a new hard drive, install Debian 12.7.0 with ALL Desktop environments
(so we are able to test/work with different Window Managers/Desktop Environments)
Then we copy all the ISO files from the USB to the /opt/iso location, and as super user (root),
we mount all these iso files and add them to the sources.list for apt, so we have access
to ALL packages. The specific steps would be as follows:
1) su/password, run as root
2) cd /opt
3) mkdir iso
4) cd iso
5) cp /media/[user]/USB_Boot/boot/iso/*.iso . (THIS WILL TAKE AWHILE!)
6) cp /home/[user]/code/mountoptiso.sh .
7) ./mountoptiso.sh
So one of the reasons for these details are to help people new to Linux to
understand what is needed to do development work. So where to start?
The Debian wiki has a Building Tutorial, so let's start there...
For reference, this is the site that covers modifying Debian source
https://wiki.debian.org/BuildingTutorial
As outlined there, the very first set of packages to be installed are listed.
Even if we aren't going to modify Debian packages, let's get these installed
so we have a good base for doing development work.
For required build tools, etc., make sure to install essentials, e.g.:
apt-get install build-essential fakeroot devscripts[Enter]
At this point, we can actually build (compile) source code and create
working programs. Let's do that with the basic Hello World! program.
See the build script and hello.c
#################################################################
#!/bin/bash
#build script
echo "Begin..."
gcc -o helloworld hello.c
if [ $? -eq 0 ]; then
echo "Hello built!"
else
echo "gcc compile failed with exit code $?"
fi
#################################################################
/***************************************************************/
/*********************************************************************************************
* hello.c
********************************************************************************************/
#include
#include
void main(void)
{
printf("Hello World!\n");
}
/***************************************************************/
For the XLib / X-Window example (buildx, hellox.c) you will
need the X11 XLib headers and libraries. The Debian package is
"libx11-dev" - to install:
apt-get install libx11-dev[Enter]
The buildx script looks like this:
#################################################################
#!/bin/bash
#buildx script
echo "Begin..."
#apt-get install libx11-dev
gcc -o helloworldx hellox.c
#gcc -o helloworldx hellox.c -lX11
if [ $? -eq 0 ]; then
echo "Hello built!"
else
echo "gcc compile failed with exit code $?"
fi
#################################################################
As noted in the comments, this package is required
We won't be including the source code due to the increasing length,
so you have to reference the file directly - hellox.c
For the GTK example (buildgtk, helloworldgtk.c) you will
need the pkgconf (Package Configuration), and the GTK-4 headers
and libraries. The Debian packages are "pkgconf" and "libgtk-4-dev"
To install:
apt-get install pkgconf[Enter]
apt-get install libgtk-4-dev[Enter]
The buildgtk script looks like this:
#################################################################
#!/bin/bash
#buildgtk script
echo "Begin..."
#apt-get install pkgconf
#apt-get install libgtk-4-dev
gcc $(pkg-config --cflags gtk4) -o helloworldgtk helloworldgtk.c $(pkg-config --libs gtk4)
if [ $? -eq 0 ]; then
echo "Hello built!"
else
echo "gcc compile failed with exit code $?"
fi
#################################################################
For the wayland example (buildwayland, hellowayland.c) you will
need the wayland headers and libraries. The Debian package is
"libwayland-dev"
To install:
apt-get install libwayland-dev[Enter]
The buildwayland script looks like this:
#################################################################
#!/bin/bash
#buildwayland script
echo "Begin..."
#apt-get install libwayland-dev
gcc -o hellowayland hellowayland.c xdg-shell-protocol.c -ggdb3 -lm -lwayland-client `pkg-config --cflags --libs pangocairo` `pkg-config --cflags --libs cairo`
#to build with full debug information add in -ggdb3
#gcc -o hellowayland hellowayland.c xdg-shell-protocol.c -ggdb3 -lm -lwayland-client `pkg-config --cflags --libs pangocairo` `pkg-config --cflags --libs cairo`
if [ $? -eq 0 ]; then
echo "Hello built!"
else
echo "gcc compile failed with exit code $?"
fi
#################################################################
As one final note, we introduce valgrind, which is a development tool that can find memory leaks.
It is too involved to go into here, but we want your to be aware of it. Refer to valgrind
documentation and examples to learn about it. Note in these 4 examples, the high-level ones
(GTK/Wayland) have memory leaks, even though there is code to clean things up on exit.
apt-get install valgrind[Enter]
View Current
View News & Commentary
View Support Items
View All
Introduction to GUI Development
November 1, 2024
Time Traveler
Category: BlogEntry
Tags: Introduction to GUI Development; Development; Graphical User Interface;
Debian Updates, some customer feedback, news clip
September 9, 2024
Time Traveler
Category: BlogEntry
Tags: Debian 12.7.0; Debian 11.11.0; Customer feedback; news;
USB Collection Updates - Most Popular, Fedora, Ubuntu
May 1, 2024
Time Traveler
Category: BlogEntry
Tags: USB Collection Updates;Most Popular;Fedora;Ubuntu
Testimonials, Feedback, Input & Updates
March 27, 2024
Time Traveler
Category: BlogEntry
Tags: Testimonials; Feedback; Input; Updates;
Happy New Year 2024!
January 2, 2024
Time Traveler
Category: BlogEntry
Tags: USB; Notes; Price; Amazon Pay; What's happening;
First Steps - How To Boot from USB
October 30, 2023
Time Traveler
Category: BlogEntry
Tags: USB; Booting; Intro; How To;
A few notes and happenings…
September 12, 2023
Time Traveler
Category: BlogEntry
Tags: USB; Notes; What's happening;
Debian 12 Bookworm now available!
June 16, 2023
Time Traveler
Category: BlogEntry
Tags: New; Debian; Bookworm; Debian 12;
Updates & Info
May 11, 2023
Time Traveler
Category: BlogEntry
Tags: New; Debian; Ubuntu; Kubuntu; OpenMandriva
Random Notes, What's Happening…
February 8, 2023
Time Traveler
Category: BlogEntry
Tags: New; UEFI; Debian
Debian Complete Collection USB now has hardware .deb packages
January 5, 2023
TimeTraveler
Category: BlogEntry
Tags: Debian; Debian Complete Collection USB; Drivers; Hardware
USB Promo / Ubuntu 22.10 updates and notes
October 27, 2022
TimeTraveler
Category: BlogEntry
Tags: Ubuntu; Ubuntu Studio; USB Promo
Partitions, setup and configuration of the Debian Complete Collection USB
September 28, 2022
TimeTraveler
Category: BlogEntry
Tags: Debian; USB Partitions; GRUB;
Some notes on Debian and Firmware
April 7, 2022
TimeTraveler
Category: BlogEntry
Tags: Debian; Ubuntu; Firmware; non-free;
Read only USB (physical write protect switch)
January 12, 2022
TimeTraveler
Category: BlogEntry
Tags: USB; Physical write protect switch; Read Only
Raspberry Pi: Reducing file system to fit on smaller SD Card
December 22, 2021
TimeTraveler
Category: BlogEntry
Tags: Debian; Raspberry Pi; Raspbian; resize2fs
Some notes on Live Linux distros
December 10, 2021
TimeTraveler
Category: SupportNote
Tags: Debian; Fedora; Ubuntu; Most Popular; USB Collections
All USB Collections updated!
November 10, 2021
TimeTraveler
Category: BlogEntry
Tags: Debian; Fedora; Ubuntu; Most Popular; USB Collections
LinuxCollections.com media production has been green for years
September 20, 2021
TimeTraveler
Category: BlogEntry
Tags: Media Production
Debian 11.0.0 Release
August 26, 2021
TimeTraveler
Category: BlogEntry
Tags: Debian; Debian 11; Release;
Debian 10.10.0 USB Developer Collection
July 8, 2021
Time Traveler
Category: BlogEntry
Tags: New; Updates; Debian;
Notes on WiFi Drivers
May 12, 2021
Time Traveler
Category:
Tags: WiFi; Wireless; Drivers; Firmware;
Cloned Drives and UUIDs
April 28, 2021
Time Traveler
Category:
Tags: UUID; lsblk; fstab;
Debian Buster (10) sources.list example
March 2, 2021
Time Traveler
Category: SupportNote
Tags: Debian; Buster; sources.list; apt; apt-get
Debian 10.8.0 USB Complete Collection
February 15, 2021
Time Traveler
Category: BlogEntry
Tags: New; Updates; Debian;
Random Notes, What's New 2021
January 22, 2021
Time Traveler
Category: BlogEntry
Tags: New; Hardware;
New! The By Request page
December 10, 2020
Time Traveler
Category: BlogEntry
Tags: New; Requests;
How to create a separate bootable USB for specific Live version from Debian USB Complete Collection
September 2, 2020
Time Traveler
Category: SupportNote
Tags: Debian; USB Complete Collection; Install; Create Live USB;
Debian catalog backfilled a bit
August 19, 2020
Time Traveler
Category: BlogEntry
Tags: Debian; Hamm; Slink; Potato; Woody;
Understanding Debian main, contrib, non-free in sources.list
August 17, 2020
Time Traveler
Category: BlogEntry
Tags: Debian; sources.list; apt-get; apt; /etc/apt;
Most Popular USB Collection now available!
July 23, 2020
Time Traveler
Category: BlogEntry
Tags: USB Collections; Fedora; Linux Lite; LinuxMint; Manjaro; MX Linux; openSuSE; Ubuntu; Kubuntu
How do I learn about all the programs available in the Debian USB Complete Collection (or the Debian all discs option)?
June 16, 2020
Time Traveler
Category: SupportNote
Tags: Debian Packages, Debian USB Complete Collection, mountusb, ISO, Synaptic, apt
How to access ALL Debian packages from LinuxCollections.com's Debian Complete Collection on USB
June 4, 2020
Time Traveler
Category: SupportNote
Tags: mountusb, ISO, Debian Packages, Debian USB Complete Collection
Older Linux Distributions
May 26, 2020
Time Traveler
Category: SupportNote
Tags: Old distributions, BIOS, UEFI, hd vs. sd
Updates - new LinuxCollections.com Disc case, Facebook Links
May 6, 2020
Time Traveler
Category: BlogEntry
Tags: LinuxCollections.com Disc Case, Facebook, Advertising
Ubuntu 20.04 LTS now available in all flavors on USB!
April 20, 2020
Time Traveler
Category: BlogEntry
Tags: Ubuntu; Kubuntu; Lubuntu; Xubuntu; Ubuntu Studio; Ubuntu Budgie; Ubuntu MATE; USB Complete Collection;
Understanding Linux on a USB Flash drive
April 20, 2020
Time Traveler
Category: SupportNote
Tags: USB Flash Drive; USB Complete Collections
What NOT to do with a Bootable USB Drive or Collection
March 31, 2020
Time Traveler
Category: SupportNote
Tags: USB Flash Drive; USB Complete Collections
Lost or forgot Admin password (root user password)
March 25, 2020
Time Traveler
Category: SupportNote
Tags: LinuxCollections.com Blog
What to expect from a Linux Disc
March 24, 2020
Time Traveler
Category: BlogEntry
Tags: LinuxCollections.com Blog
Issues with new Debian 10 install - no Desktop / login prompt only
March 14, 2020
Time Traveler
Category: SupportNote
Tags: LinuxCollections.com Blog
Solving Problems
January 28, 2020
Time Traveler
Category: SupportNote
Tags: LinuxCollections.com Blog
US Postage rates go up
January 28, 2020
Time Traveler
Category: BlogEntry
Tags: LinuxCollections.com Blog
Need a different operating system
January 25, 2020
Time Traveler
Category: BlogEntry
Tags: LinuxCollections.com Blog
Support Stories - Disc Data
January 15, 2020
Time Traveler
Category: SupportNote
Tags: LinuxCollections.com Blog
The Facebook Link Conundrum
January 10, 2020
Time Traveler
Category: BlogEntry
Tags: LinuxCollections.com Blog
Welcome to the LinuxCollections.com Blog!
January 6, 2020
Time Traveler
Category: BlogEntry
Tags: LinuxCollections.com Blog