Unix 和 Linux
2.2.1. 预编译的包
gtkmm 最新的版本的软件包几乎存在于今天每一个主流的 Linux 发布版本中。所以,如果你使用 Linux,你可能只需要从官方的软件库安装相应的软件包,然后就可以开始使用 gtkmm 了。已经在它们的软件库里面包含了 gtkmm 的发布版本有:Debian、Ubuntu、Red Hat、Fedora、Mandriva、SuSE 等等。
The names of the gtkmm packages vary from distribution to distribution (e.g. libgtkmm-3.0-dev on Debian and Ubuntu or gtkmm30-devel on Red Hat Fedora), so check with your distribution's package management program for the correct package name and install it like you would any other package.
The package names will not change when new API/ABI-compatible versions of gtkmm are released. Otherwise they would not be API/ABI-compatible. So don't be surprised, for instance, to find gtkmm 3.24 supplied by Debian's libgtkmm-3.0-dev package.
2.2.2. 从源代码安装
If your distribution does not provide a pre-built gtkmm package, or if you want to install a different version than the one provided by your distribution, you can also install gtkmm from source. The source code for gtkmm can be downloaded from https://download.gnome.org/sources/gtkmm/.
After you've installed all of the dependencies, download the gtkmm source code, unpack it, and change to the newly created directory. gtkmm 3.24.2 and earlier can be built and installed with the following sequence of commands:
# ./configure # make # make install
gtkmm 3.24.3 and later can be built with Meson. See the README file in the gtkmm version you've downloaded.
Remember that on a Unix or Linux operating system, you will probably need to be root to install software. The su or sudo command will allow you to enter the root password and have root status temporarily.
The configure script or meson will check to make sure all of the required dependencies are already installed. If you are missing any dependencies, it will exit and display an error.
By default, gtkmm if built with Autotools, will be installed under the /usr/local directory. On some systems you may need to install to a different location. For instance, on Red Hat Linux systems you might use the --prefix option with configure, like so:
# ./configure --prefix=/usr
在安装到标准系统前缀时,如 /usr,你必须非常小心。Linux 发行版会安装软件到 /usr,所以安装源代码包到这个位置可能会破坏或与使用软件包管理器安装的软件冲突。理想情况下,你应当将从源代码安装的软件都安装到一个独立位置。
如果你想帮助开发 gtkmm,或实验一些新的功能,你也可以直接从 Git 安装 gtkmm。大多数用户绝对不需要这么做,但是如果你对帮助 gtkmm 开发感兴趣,请看附录:使用 gtkmm 源代码。