第133页的gtk+编程例子——计算器应用练习从源代码编译gnome-calculator-45.0.2
第133页的gtk+编程例子——计算器应用练习从源代码编译gnome-calculator-45.0.2
以前在linux编译安装软件的步骤是
./configure
make
make install
make uninstall
如今就是
mkdir buildxxxxxxxx
meson setup buildxxxxxxxx
cd buildxxxxxxxx
ninja
ninja install
ninja uninstall
如今也很少有软件是让用户从源代码编译,直接提供rpm和deb格式包下载,同时提供repo文件下载让你使用dnf或者apt能够实时更新下载并解决依赖关系
在openSUSE-Leap-15.6-DVD-x86_64的gnome41.8桌面环境,它已经自带有gnome-calculator版本为45.0.2
应用程序——工具——终端
ruhong@localhost:~>
ruhong@localhost:~> gnome-calculator --version
gnome-calculator 45.0.2
ruhong@localhost:~> which gnome-calculator
/usr/bin/gnome-calculator
应用程序——互联网——firefox——打开https://gitlab.gnome.org/GNOME/gnome-calculator
网页左边——单击main——gnome-45protected——网页右边——单击Code——tar.gz——下载gnome-calculator-gnome-45.tar.gz,大小为2.4MB
应用程序——工具——终端
ruhong@localhost:~> su -
密码:
localhost:~ # ls -lh /home/ruhong/download/gnome-calculator-gnome-45.tar.gz
-rw-r–r-- 1 ruhong users 2.4M Jan 20 17:40 /home/ruhong/download/gnome-calculator-gnome-45.tar.gz
localhost:~ # tar -zxvf /home/ruhong/download/gnome-calculator-gnome-45.tar.gz -C /root
localhost:~ # cd gnome-calculator-gnome-45/
localhost:~/gnome-calculator-gnome-45 # head NEWS
Overview of changes in gnome-calculator 45.0.2
* Updated translations
Overview of changes in gnome-calculator 45.0.1
* Retagging release
Overview of changes in gnome-calculator 45.rc
* Updated translations
Overview of changes in gnome-calculator 45.0
localhost:~/gnome-calculator-gnome-45 # mkdir build20260120
localhost:~/gnome-calculator-gnome-45 # meson setup build20260120/
The Meson build system
Version: 1.3.1
Source dir: /root/gnome-calculator-gnome-45
Build dir: /root/gnome-calculator-gnome-45/build20260120
…
Program msgfmt found: YES (/usr/bin/msgfmt)
Program valadoc found: YES (/usr/bin/valadoc)
Build targets in project: 217
WARNING: Broken features used:
- 1.3.0: {‘install kwarg with non-boolean value’}
Found ninja-1.10.0 at /usr/bin/ninja
这一步类似./configure,它会报错系统缺少meson,就使用zypper search meson搜索一下,再使用zypper install meson补安装一下,再次运行meson setup build20260120/,再报错缺少,再补安装,直到没有报错为止
localhost:~/gnome-calculator-gnome-45 # zypper search meson
localhost:~/gnome-calculator-gnome-45 # zypper install meson vala valadoc valadoc-doclet-devhelp cmake libgee-devel mpc-devel libadwaita-devel itstool
localhost:~/gnome-calculator-gnome-45 # cd build20260120/
localhost:~/gnome-calculator-gnome-45/build20260120 # ninja
[123/293] Compiling Vala source …/lib/currency.vala …/li…/lib/serializer.vala …/lib/unit.vala libmpfr/mpfrg.vapi
…/lib/equation-parser.vala:1307.5-1307.34: warning: Method `Parser.destroy_all_nodes’ never used
1307 | private void destroy_all_nodes (ParseNode node)
…
这一步类似make
localhost:~/gnome-calculator-gnome-45/build20260120 # ninja
ninja: no work to do.
localhost:~/gnome-calculator-gnome-45/build20260120 # ninja install
…
Installing data/org.gnome.Calculator.desktop to /usr/local/share/applications
Installing data/org.gnome.Calculator.appdata.xml to /usr/local/share/metainfo
Installing src/gnome-calculator to /usr/local/bin
Installing src/gcalccmd to /usr/local/bin
…
这一步类似make install,安装到系统中
localhost:~/gnome-calculator-gnome-45/build20260120 # which gnome-calculator
/usr/local/bin/gnome-calculator
localhost:~/gnome-calculator-gnome-45/build20260120 # ls -lh /usr/local/bin/gnome-calculator
-rwxr-xr-x 1 root root 2.0M Jan 20 2026 /usr/local/bin/gnome-calculator
localhost:~/gnome-calculator-gnome-45/build20260120 # /usr/local/bin/gnome-calculator
是能够成功运行的,默认安装在/usr/local/bin/,而系统自带的就在/usr/bin
localhost:~/gnome-calculator-gnome-45/build20260120 # ls -lh /usr/bin/gnome-calculator
-rwxr-xr-x 1 root root 735K May 9 2024 /usr/bin/gnome-calculator
卸载/usr/local/bin/gnome-calculator
localhost:~/gnome-calculator-gnome-45/build20260120 # ninja uninstall
…
Deleted: /usr/local/share/locale/am/LC_MESSAGES
Deleted: /usr/local/share/locale/am
Deleted: /usr/local/share/locale/af/LC_MESSAGES
Deleted: /usr/local/share/locale/af
Deleted: /usr/local/share/locale/ab/LC_MESSAGES
Deleted: /usr/local/share/locale/ab
Uninstall finished.
Deleted: 1742
Failed: 0
Remember that files created by custom scripts have not been removed.
这一步类似make uninstall
localhost:~/gnome-calculator-gnome-45/build20260120 #
localhost:~/gnome-calculator-gnome-45/build20260120 # ls src/gnome-calculator.p/
gnome-calculator.c math-preferences.c meson-generated_math-display.c.o
math-buttons.c math-variable-popover.c meson-generated_math-function-popover.c.o
math-converter.c math-window.c meson-generated_math-history.c.o
math-display.c meson-generated_…_org.gnome.Calculator.c.o meson-generated_math-popover.c.o
math-function-popover.c meson-generated_gnome-calculator.c.o meson-generated_math-preferences.c.o
math-history.c meson-generated_math-buttons.c.o meson-generated_math-variable-popover.c.o
math-popover.c meson-generated_math-converter.c.o meson-generated_math-window.c.o
localhost:~/gnome-calculator-gnome-45/build20260120 #
在/root/gnome-calculator-gnome-45/build20260120/src/gnome-calculator.p里面有许多.c文件,是由vala语言文件转换成c语言文件,都是非常复杂的,无法阅读明白
