This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
programming:gtk4 [2022/03/20 19:00] nanodano [gtkmm (C++)] |
programming:gtk4 [2022/03/21 05:19] (current) nanodano |
||
---|---|---|---|
Line 127: | Line 127: | ||
You can use [[http:// | You can use [[http:// | ||
+ | |||
+ | You might need some other dependencies like: | ||
+ | |||
+ | * sigc++-3.0 | ||
+ | * gtk4 | ||
+ | * glibmm-2.68 | ||
+ | * cairomm-1.16 | ||
+ | * pangomm-2.48 | ||
+ | |||
+ | |||
+ | To build from source: | ||
+ | |||
<code bash> | <code bash> | ||
- | # Version 4.6.0 from https://download.gnome.org/sources/gtkmm/ | + | # Install mm-common |
+ | sudo apt install mm-common | ||
+ | |||
+ | # Build and install libsigc++3 | ||
+ | # https:// | ||
+ | wget https:// | ||
+ | tar xzf libsigc++-3.2.0 | ||
+ | cd libsigc++-3.2.0 | ||
+ | cmake . | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | # glibmm | ||
+ | # https://gitlab.gnome.org/GNOME/glibmm | ||
+ | wget https:// | ||
+ | tar xzf glibmm-2.70.0.tar.gz | ||
+ | cd glibmm-2.70.0 | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | # cairomm | ||
+ | # https:// | ||
+ | wget https:// | ||
+ | tar xBf cairomm-1.16.1.tar.xz | ||
+ | cd cairomm-1.16.1 | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | # pangomm | ||
+ | # https:// | ||
+ | wget https:// | ||
+ | tar xzf pangomm-2.50.0.tar.gz | ||
+ | cd pangomm-2.50.0 | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | |||
+ | # gtkmm | ||
wget https:// | wget https:// | ||
tar xBf gtkmm-4.6.0.tar.xz | tar xBf gtkmm-4.6.0.tar.xz | ||
cd gtkmm-4.6.0 | cd gtkmm-4.6.0 | ||
- | meson setup builddir | + | ./ |
- | meson build | + | make |
+ | sudo make install | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | When compiling, use '' | ||
+ | |||
+ | <code bash> | ||
+ | # Compile app with gtk4 | ||
+ | g++ main.cpp `pkg-config gtkmm-4.0 --cflags --libs` -std=c++20 | ||
+ | |||
+ | # Set path for shared library when running | ||
+ | LD_LIBRARY_PATH=/ | ||
+ | </ | ||
+ | |||
+ | Here is a gtkmm hello world: | ||
+ | |||
+ | <code cpp main.cpp> | ||
+ | // gtkmm4 example | ||
+ | |||
+ | // Compile with: | ||
+ | // g++ main.cpp `pkg-config gtkmm-4.0 --cflags --libs` -std=c++20 | ||
+ | |||
+ | // Run with | ||
+ | // LD_LIBRARY_PATH=/ | ||
+ | #include < | ||
+ | |||
+ | class MyWindow : public Gtk:: | ||
+ | { | ||
+ | public: | ||
+ | MyWindow(); | ||
+ | }; | ||
+ | |||
+ | MyWindow:: | ||
+ | { | ||
+ | set_title(" | ||
+ | set_default_size(200, | ||
+ | } | ||
+ | |||
+ | int main(int argc, char* argv[]) | ||
+ | { | ||
+ | auto app = Gtk:: | ||
+ | return app-> | ||
+ | } | ||
</ | </ |