From 83be52c91afbf47f7b2d4d003fe5a98a7e3c9cfe Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sun, 5 Mar 2023 11:37:31 -0500 Subject: [PATCH] Create example --- .gitignore | 1 + CMakeLists.txt | 13 ++++++++++ README.md | 7 +++++ compile.sh | 8 ++++++ install.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ main.cpp | 16 ++++++++++++ 6 files changed, 114 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 compile.sh create mode 100644 install.sh create mode 100644 main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..312aba7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,13 @@ +PROJECT ( example ) + +cmake_minimum_required( VERSION 3.22 ) + +FIND_PACKAGE ( PkgConfig REQUIRED ) +PKG_CHECK_MODULES( GTK REQUIRED gtkmm-4.0) +INCLUDE_DIRECTORIES ( ${GTK_INCLUDE_DIRS} ) + + + +ADD_EXECUTABLE ( example main.cpp ) +TARGET_LINK_LIBRARIES( example ${CMAKE_THREAD_LIBS_INIT} ${GTK_LIBRARIES} ) + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e58801c --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# GTK Example + +### Ubuntu + +```bash +sudo apt install libgtkmm-2.4-dev +``` \ No newline at end of file diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..2cbbf7a --- /dev/null +++ b/compile.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +#g++ main.cpp $(pkg-config gtkmm-4.0 --cflags --libs) + +mkdir -p build +cd build +cmake .. +make \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..000d64f --- /dev/null +++ b/install.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +set -e + +# https://terminalroot.com/how-to-install-gtkmm-4-on-ubuntu-2204/ +# https://www.devdungeon.com/wiki/doku.php?id=programming:gtk4 + +#sudo apt install build-essential git g++ autotools-dev libgtkmm-3.0-dev \ +# libgtkmm-3.0-doc mm-common libgtk-4-bin \ +# libgtk-4-common libgtk-4-dev libgtk-4-doc pkg-config + +if [ ! -f libsigc++-3.0.7.tar.xz ]; then + wget https://download.gnome.org/sources/libsigc++/3.0/libsigc++-3.0.7.tar.xz +fi +tar Jxvf libsigc++-3.0.7.tar.xz +cd libsigc++-3.0.7/ +./autogen.sh --prefix=/usr/local +make -j`nproc --ignore=2` +sudo make install + +if [ ! -f glibmm-2.68.2.tar.xz ]; then + wget https://download.gnome.org/sources/glibmm/2.68/glibmm-2.68.2.tar.xz +fi +tar Jxvf glibmm-2.68.2.tar.xz +cd glibmm-2.68.2/ +./autogen.sh --prefix=/usr +make -j`nproc --ignore=2` +sudo make install + +cd .. + +if [ ! -d cairomm ]; then + git clone https://github.com/freedesktop/cairomm.git +fi +cd cairomm +./autogen.sh --prefix=/usr +make -j`nproc --ignore=2` +sudo make install + +cd .. + +if [ ! -f pangomm-2.50.0.tar.xz ]; then + wget https://download.gnome.org/sources/pangomm/2.50/pangomm-2.50.0.tar.xz +fi +tar Jxvf pangomm-2.50.0.tar.xz +cd pangomm-2.50.0/ +./autogen.sh --prefix=/usr +make -j`nproc --ignore=2` +sudo make install + +cd .. + +ls /usr/lib/libsigc-3* + +sudo ln -s /usr/local/lib/libsigc-3.0.so.0.0.0 /usr/lib/libsigc-3.0.so.0.0.0 +sudo ln -s /usr/local/lib/libsigc-3.0.la /usr/lib/libsigc-3.0.la +sudo ln -s /usr/local/lib/libsigc-3.0.so /usr/lib/libsigc-3.0.so +sudo ln -s /usr/local/lib/libsigc-3.0.so.0 /usr/lib/libsigc-3.0.so.0 + +if [ ! -f gtkmm-4.6.1.tar.xz ]; then + wget https://download.gnome.org/sources/gtkmm/4.6/gtkmm-4.6.1.tar.xz + wget https://download.gnome.org/sources/gtkmm/4.6/gtkmm-4.6.1.sha256sum + sha256sum -c --ignore-missing gtkmm-4.6.1.sha256sum +fi +tar Jxvf gtkmm-4.6.1.tar.xz +cd gtkmm-4.6.1 +./autogen.sh --prefix=/usr +make -j`nproc --ignore=2` +sudo make install \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..13b5c1d --- /dev/null +++ b/main.cpp @@ -0,0 +1,16 @@ +#include + +class GTKExample : public Gtk::Window { +public: + GTKExample(); +}; + +GTKExample::GTKExample(){ + set_title("GTK Example"); + set_default_size(800, 450); +} + +int main(int argc, char ** argv){ + auto app = Gtk::Application::create("com.example.gtk"); + return app->make_window_and_run(argc, argv); +} \ No newline at end of file