(一)从源码编译安装GTK开发环境
为了便于获取源码,截止2015-05-26的gtk相关源码的存放于网盘中:
1. 相关网址
2)Compiling the GTK+ libraries
Overview of GTK+ and its Libraries
2.下载和编译源码包
1)下载源码: (版本:gtk+-3.16.3.tar.xz)
2)解压配置gtk源码
$ tar xvfJ gtk+-3.16.3.tar.xz $ cd gtk+-3.16.3/ $ ./configure --prefix=/opt/gtk
编译GTK需要依赖 glib、atk、pango、cairo、gdk-pixbuf等软件包。
3)编译配置glib及其依赖包zlib、libffi
a.编译安装libffi-3.2.1(http://www.sourceware.org/libffi/)
采用默认configure
b.编译安装zlib-1.2.8(http://www.zlib.net/)
采用默认configure
c. 编译安装glib-2.44.1
$ ./configure --prefix=/opt/glib-2.44.1 $make $sudo make install
由于未采取默认配置,设置了自定义安装目录,因此需要声明变量PKG_CONFIG_PATH和LD_LIBRARY_PATH。
以glib为例,.pc文件位于 package/lib/pkgconfig目录下,则添加文件set_pkg_config_path_glib-2.0声明PKG_CONFIG_PATH变量和LD_LIBRAY_PATH
$cat /opt/glib-2.44.1/set_pkg_config_path_glib-2.0 export PKG_CONFIG_PATH=/opt/glib-2.44.1/lib/pkgconfig:$PKG_CONFIG_PATH export LD_LIBRARY_PATH=/opt/glib-2.44.1/lib:$LD_LIBRAY_PATH
对其它的五个package(atk、cairo、pango、cairo-gobject、gdk-pixbuf-2.0)依次采用针对glib-2.0的编译安装和配置方法,解决GTK对多个库依赖问题。
d.编译安装gobject
配置gobject,Error:未发现Python头文件( configure: error: Python headers not found)
Solution:
$sudo apt-get install python-dev //没有安装python源代码,报找不到 Python.h的头文件错误
e.下载编译gdk-pixbuf(http://www.linuxfromscratch.org/blfs/view/svn/x/.html)
gdk-pixbuf依赖glib、libjpeg-turbo、libpng、libtiff,这几个包需要先编译安装。
Gdk Pixbuf Dependencies
RequiredGLib-2.44.1, libjpeg-turbo-1.4.0, libpng-1.6.17 and LibTIFF-.0.3
Recommended
Xorg Libraries (Many GTK+ applications require gdk-pixbuf-xlib).
Optional (Required if building GNOME)
gobject-introspection-1.44.0
Optional: JasPer-1.900.1 and GTK-Doc-1.22
eg.如果为安装libxi则配置时出现如下错误:
Solution:
$ sudo apt-get install libxi-dev
f.下载编译cairo源码(http://cairographics.org/)
configure信息:
g.编译安装pango
pango依赖cairo、glib、freetype,所以这些包需要先编译安装,或者使用
$sudo apt-get install gcc g++ libfreetype6-dev libglib2.0-dev libcairo2-dev
$ ./configure --prefix=/opt/pango
configure: error: *** Could not enable any backends.
*** Must have at least one backend to build Pango.
过程中可能还会依赖bzip2,需要补充编译安装。
编译freetype出错:
一般是64位系统出现此问题,Makefile中CFLAGS加参数-fPIC,使用64位元的方法进行编译。
h. 编译安装atk
参考资料
a) GTK+安装笔记
b)CentOS编译安装GIMP
c)checking which cairo font backends could be used... none
d)libbz2.a,libz.so导致tokyocabinet make失败问题解决方法
$sudo make $sudo make install
安装成功:
Error
Couldn‘t find include ‘GdkPixbuf-2.0.gir‘ (search path: [‘../gdk‘, ‘/usr/share/gnome/gir-1.0‘, ‘/usr/local/share/gir-1.0‘, ‘/usr/share/gir-1.0‘, ‘/usr/local/share/gir-1.0‘, ‘/usr/share/gir-1.0‘, ‘/usr/local/share/gir-1.0‘])
Solution:
configure时添加参数 --enable-introspection=no(默认为yes)
测试是否安装成功--运行demo程序:
~/src/gtk+-3.16.3/demos/gtk-demo$ ./gtk3-demo
参考链接:
There are the depandency problem
and the library I install to solve the problem:
glib-2.40.0
problem
configure: error: * Working zlib library and headers not found *
solve: sudo apt-get install ruby
sudo apt-get install zlib1g-dev
problem
configure: error: Package requirements (libffi >= 3.0.0) were not met:
solve sudo apt-get install libffi-dev
gdk-pixbuf-2.30.8
problem
configure: WARNING: *** TIFF loader will not be built (TIFF library not found)`
solve sudo apt-get install libtiff4-dev
problem
configure: WARNING: * PNG loader will not be built (PNG library not found)*
configure: WARNING: * PNG loader will not be built (PNG header file not found) * ````
solve sudo apt-get install libpng-dev
gobject-introspection-1.40.0
problem
configure: error: flex not found but required
solve sudo apt-get install flex
problem
configure: error: bison not found but required
solve sudo apt-get install bison
problem
configure: error: Python headers not found
solve sudo apt-get install python-dev
pango-1.36.5
problem
configure: error: *** Could not enable any backends.
solve sudo apt-get install libcairo-dev
sudo apt-get install libcairomm-1.0-dev
What‘s more, I also install
HarfBuzz
. I download the source filehttp://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.22.tar.bz2
and compile it.
gtk+-3.12.2
problem
configure: error: *** XInput2 extension not found. Check ‘config.log‘ for more details.
solve sudo apt-get install libXi-dev
problem
configure: error: Package requirements (atk atk-bridge-2.0) were not met:
No package ‘atk-bridge-2.0‘ found
Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.
Alternatively, you may set the environment variables ATK_CFLAGS and ATK_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
solve sudo apt-get install libatk-bridge2.0-dev
problem
Couldn‘t find include ‘GdkPixbuf-2.0.gir‘ (search path: [‘../gdk‘, ‘/usr/share/gnome/gir-1.0‘, ‘/usr/local/share/gir-1.0‘, ‘/usr/share/gir-1.0‘, ‘/usr/local/share/gir-1.0‘, ‘/usr/share/gir-1.0‘, ‘/usr/local/share/gir-1.0‘]) make[4]: * [Gdk-3.0.gir] Error 1 make[4]: Leaving directory
/home/simowce/GTK/gtk+-3.12.2/gdk‘ make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory
/home/simowce/GTK/gtk+-3.12.2/gdk‘ make[2]: * [all] Error 2 make[2]: Leaving directory/home/simowce/GTK/gtk+-3.12.2/gdk‘ make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory
/home/simowce/GTK/gtk+-3.12.2‘ make: *** [all] Error 2`
solve sudo apt-get install gobject-introspection
What‘ s more, I also install
gdk-pixbuf
from the source file from HERE.
problem
Couldn‘t find include ‘Atk-1.0.gir‘
solve
To solve this problem, I download
ATK-2.14.0
fromhttp://ftp.gnome.org/pub/gnome/sources/atk/2.14/atk-2.14.0.tar.xz
.Then, I build it by using the listed command:
./configure --prefix=/usr make sudo amek install
2. BLFS Book - Version 2012-04-04 Enhancement gtk+-3.2.4
About the error of couldn‘t find include ‘gdkpixbuf-2.0.gir‘. One solution is add --enable-introspection=no while configuring. The other one is install Gobject Introspection before atk, pango alnd gdk-pixbuf.
On the Gtk+-3 page it already says that if you want introspection support you need to install Gobject Introspection before you install Atk, Pango and Gdk-Pixbuf. If you don‘t need introspection support and you‘re getting an error because of Gobject-Introspection the obvious solution is to configure with --disable-introspection.
PS:如果提示缺少某个Package,一个简单的方法时使用命令 apt-catch search PackageName,然后apt-get install 相应package的dev支持库。
关于pkg-config
1. /etc/ld.so.conf : 文件记录了编译时使用的动态链接库的路径
如果不修改/etc/ld.so.conf使用非默认路径下的库文件-----LD_LIBRARY_PATH
环境变量LD_LIBRARY_PATH列出了查找共享库时除了默认路径之外的其他路径。如果不想修改或无法修改(无root权限)/etc/ld.so.conf而使用其他路径下的库文件就需要设置LD_LIBRARY_PATH了,例:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib 这样就可以使用/opt/lib下的库文件。
2. ldconfig - configure dynamic linker run-time bindings
root命令,其作用是将/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用。因此当安装完一些库文件(例如刚安装好glib),或者修改ld.so.conf增加新的库路径后,需要运行一下/sbin/ldconfig,使所有的库文件都被缓存到ld.so.cache中,否则即使库文件就在/usr/lib下,也会不被使用,结果是编译过程中报错,缺少xxx库。
3.PKG_CONFIG_PATH & LD_LIBRARY_PATH
pkg-config是向configure程序提供系统信息的程序,比如软件的版本,库的版本、路径等等,并且这些信息只在编译时使用。pkg-config要求库提供一个.pc元数据文件,从这些文件中检索库的各种必要信息,包括版本信息,编译和连接需要的参数等。这些信息可以通过pkg-config提供的参数(如--cflags, --libs)单独提取出来直接供编译器和连接器使用。默认情况下,每个支持pkg-config的库对应的.pc文件,在安装后,都位于目录/usr/lib/pkgconfig目录下。环境变量PKG_CONFIG_PATH是用来设置.pc文件的搜索路径。
/usr/lib/pkgconfig
4. 参考文档:
1). pkg-config使用
2).PKG_CONFIG_PATH变量 与 ld.so.conf 文件
(二)通过apt-get自动安装GTK开发软件包及其相关依赖包
$ sudo apt-get install build-essential $ sudo apt-get install gnome-core-devel
参考链接:
运行命令 apt-get install gnome-core-devel 之后显示的依赖包信息:
The following extra packages will be installed: autoconf automake autopoint autotools-dev debhelper devhelp devhelp-common dh-apparmor docbook docbook-dsssl docbook-to-man docbook-xml docbook-xsl doxygen evince evolution-data-server evolution-data-server-common evolution-data-server-dev evolution-data-server-online-accounts gir1.2-brasero-3.0 gir1.2-caribou-1.0 gir1.2-champlain-0.12 gir1.2-clutter-1.0 gir1.2-clutter-gst-1.0 gir1.2-cogl-1.0 gir1.2-coglpango-1.0 gir1.2-ebook-1.2 gir1.2-ebookcontacts-1.2 gir1.2-edataserver-1.2 gir1.2-evince-3.0 gir1.2-farstream-0.2 gir1.2-folks-0.6 gir1.2-freedesktop gir1.2-gck-1 gir1.2-gconf-2.0 gir1.2-gcr-3 gir1.2-gdesktopenums-3.0 gir1.2-gee-0.8 gir1.2-geocodeglib-1.0 gir1.2-gkbd-3.0 gir1.2-glib-2.0 gir1.2-gnomebluetooth-1.0 gir1.2-gnomedesktop-3.0 gir1.2-gst-plugins-base-0.10 gir1.2-gstreamer-0.10 gir1.2-gtk-2.0 gir1.2-gtk-3.0 gir1.2-gtkchamplain-0.12 gir1.2-gtkclutter-1.0 gir1.2-gtop-2.0 gir1.2-gucharmap-2.90 gir1.2-gweather-3.0 gir1.2-gxps-0.1 gir1.2-javascriptcoregtk-3.0 gir1.2-json-1.0 gir1.2-mutter-3.0 gir1.2-nautilus-3.0 gir1.2-networkmanager-1.0 gir1.2-nmgtk-1.0 gir1.2-panelapplet-4.0 gir1.2-pango-1.0 gir1.2-rest-0.7 gir1.2-rsvg-2.0 gir1.2-telepathyglib-0.12 gir1.2-webkit-3.0 gir1.2-wnck-3.0 gir1.2-xkl-1.0 gjs gnome-api-docs gnome-bluetooth gnome-common gnome-desktop3-data gnome-devel-docs gnome-js-common gnome-platform-devel gobject-introspection graphviz gsettings-desktop-schemas-dev gstreamer1.0-doc gtk-doc-tools intltool itstool jade libarchive-dev libarchive13 libatk-bridge2.0-dev libatk1.0-dev libatk1.0-doc libatkmm-1.6-dev libatspi2.0-dev libbrasero-media3-dev libcairo-gobject2 libcairo-script-interpreter2 libcairo2 libcairo2-dev libcairo2-doc libcairomm-1.0-dev libcamel-1.2-45 libcamel1.2-dev libcanberra-doc libcaribou-common libcaribou-dev libcaribou0 libcdt5 libcgraph6 libchamplain-0.12-0 libchamplain-0.12-dev libchamplain-gtk-0.12-0 libchamplain-gtk-0.12-dev libclutter-1.0-dev libclutter-1.0-doc libclutter-gst-1.0-0 libclutter-gst-dev libclutter-gtk-1.0-0 libclutter-gtk-1.0-dev libclutter-gtk-1.0-doc libcogl-dev libcogl-doc libcogl-pango-dev libcroco3-dev libdbus-1-3 libdbus-1-dev libdbus-glib-1-dev libdconf-dev libdconf-doc libdevhelp-3-2 libdrm-dev libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libebackend-1.2-7 libebackend1.2-dev libebook-1.2-14 libebook-contacts-1.2-0 libebook-contacts1.2-dev libebook1.2-dev libecal-1.2-16 libecal1.2-dev libedata-book-1.2-20 libedata-book1.2-dev libedata-cal-1.2-23 libedata-cal1.2-dev libedataserver-1.2-18 libedataserver1.2-dev libegl1-mesa libegl1-mesa-dev libegl1-mesa-drivers libencode-locale-perl libevdocument3-4 libevince-dev libevview3-3 libexpat1-dev libfarstream-0.2-dev libffi-dev libfile-listing-perl libfolks-dev libfont-afm-perl libfontconfig1-dev libfreetype6 libfreetype6-dev libgail-3-0 libgail-3-dev libgail-3-doc libgail-common libgail-dev libgail-doc libgail18 libgbm-dev libgbm1 libgck-1-dev libgconf2-dev libgconf2-doc libgcr-3-dev libgdk-pixbuf2.0-dev libgdk-pixbuf2.0-doc libgee-0.8-dev libgeocode-glib-dev libgeocode-glib0 libgirepository-1.0-1 libgirepository1.0-dev libgjs-dev libgjs0e libgl1-mesa-dev libgl1-mesa-glx libglapi-mesa libgles2-mesa libgles2-mesa-dev libglib2.0-0 libglib2.0-bin libglib2.0-dev libglib2.0-doc libglibmm-2.4-dev libgmime-2.6-dev libgnome-bluetooth-dev libgnome-bluetooth11 libgnome-desktop-3-7 libgnome-desktop-3-dev libgnome-keyring-dev libgnome-menu-3-dev libgnomekbd-dev libgstreamer-plugins-base0.10-dev libgstreamer-plugins-base1.0-dev libgstreamer0.10-dev libgstreamer1.0-dev libgtk-3-0 libgtk-3-dev libgtk-3-doc libgtk2.0-0 libgtk2.0-bin libgtk2.0-dev libgtk2.0-doc libgtkmm-3.0-dev libgtksourceview-3.0-dev libgtksourceview-3.0-doc libgtop2-dev libgucharmap-2-90-dev libgvc6 libgvpr2 libgweather-3-6 libgweather-3-dev libgxps-dev libharfbuzz-dev libharfbuzz-gobject0 libharfbuzz-icu0 libharfbuzz0b libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libical-dev libice-dev libio-html-perl libjavascriptcoregtk-3.0-0 libjavascriptcoregtk-3.0-dev libjson-glib-dev libltdl-dev liblwp-mediatypes-perl liblwp-protocol-https-perl libmail-sendmail-perl libmirclient-dev libmirclient7 libmirclientplatform-mesa libmirprotobuf-dev libmirprotobuf0 libmozjs-24-0 libmozjs-24-bin libmozjs-24-dev libmutter-dev libmutter0c libnautilus-extension-dev libnautilus-extension1a libnet-http-perl libnm-glib-dev libnm-glib4 libnm-gtk-common libnm-gtk-dev libnm-gtk0 libnm-util-dev libnm-util2 libnotify-dev libnotify-doc libnspr4 libnspr4-dev libnss3 libnss3-1d libnss3-dev libnss3-nssdb libp11-kit-dev libpanel-applet-4-0 libpanel-applet-4-dev libpanel-applet-4-doc libpango-1.0-0 libpango1.0-0 libpango1.0-dev libpango1.0-doc libpangocairo-1.0-0 libpangoft2-1.0-0 libpangomm-1.4-dev libpangoxft-1.0-0 libpathplan4 libpcre3-dev libpcrecpp0 libpeas-dev libpixman-1-dev libpng12-dev libprotobuf-dev libprotobuf-lite8 libpthread-stubs0-dev libpython-dev libpython2.7-dev librest-dev librsvg2-dev libsecret-1-dev libseed-gtk3-0 libseed-gtk3-dev libsigc++-2.0-dev libsigsegv2 libsm-dev libsoup-gnome2.4-dev libsoup2.4-dev libsp1c2 libsqlite3-dev libstartup-notification0-dev libsys-hostname-long-perl libtasn1-3-bin libtasn1-3-dev libtasn1-6 libtasn1-6-dev libtasn1-bin libtelepathy-farstream-dev libtelepathy-glib-dev libtelepathy-glib-doc libtool libtotem-plparser-dev libudev-dev libudev1 libudisks2-dev libvala-0.22-0 libvte-2.90-dev libvte-2.90-doc libwacom-dev libwayland-dev libwayland-egl1-mesa libwebkitgtk-3.0-0 libwebkitgtk-3.0-common libwebkitgtk-3.0-dev libwebkitgtk-common-dev libwnck-3-0 libwnck-3-dev libwww-perl libwww-robotrules-perl libx11-dev libx11-doc libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxext6 libxfixes-dev libxfixes3 libxft-dev libxi-dev libxi6 libxinerama-dev libxkbcommon-dev libxkbfile-dev libxklavier-dev libxml-parser-perl libxml2 libxml2-dev libxml2-doc libxml2-utils libxrandr-dev libxrender-dev libxrender1 libxres-dev libxshmfence-dev libxtst-dev libxxf86vm-dev m4 mesa-common-dev mircommon-dev mm-common mutter-common network-manager-dev network-manager-gnome po-debconf policykit-1-doc python-dev python-gi python-gi-cairo python-gi-dev python-gobject-2-dev python-gobject-dev python-mako python-markupsafe python2.7-dev python3-gi python3-gi-cairo sgml-data sp udev valac valac-0.22 valac-0.22-vapi x11proto-composite-dev x11proto-core-dev x11proto-damage-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev x11proto-kb-dev x11proto-randr-dev x11proto-record-dev x11proto-render-dev x11proto-resource-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xorg-sgml-doctools xsltproc xtrans-dev yelp-tools zlib1g-dev Suggested packages: autoconf2.13 autoconf-archive gnu-standards autoconf-doc dh-make apparmor-easyprof docbook-defguide psgml jadetex docbook-dsssl-doc dbtoepub docbook-xsl-doc-html docbook-xsl-doc-pdf docbook-xsl-doc-text docbook-xsl-doc docbook-xsl-saxon fop libsaxon-java libxalan2-java libxslthl-java xalan doxygen-latex doxygen-doc doxygen-gui unrar evolution evolution-data-server-dbg python-doc graphviz-doc lrzip libatkmm-1.6-doc libcairomm-1.0-doc libchamplain-doc libclutter-gst-doc libgck-1-doc libgcr-3-doc libgeocode-glib-doc libgirepository1.0-doc libglibmm-2.4-doc gstreamer0.10-doc libgtkmm-3.0-doc libdata-dump-perl libice-doc libjson-glib-doc libtool-doc libcrypt-ssleay-perl ttf-baekmuk ttf-arphic-gbsn00lp ttf-arphic-bsmi00lp ttf-arphic-gkai00mp ttf-arphic-bkai00mp imagemagick libpeas-doc librsvg2-doc seed-doc libsigc++-2.0-doc libsm-doc libsoup2.4-doc sqlite3-doc automaken gfortran fortran95-compiler gcj-jdk libauthen-ntlm-perl libxcb-doc libxext-doc network-manager-openconnect-gnome network-manager-openvpn-gnome network-manager-vpnc-gnome libmail-box-perl python-beaker python-mako-doc perlsgml w3-recs opensp The following NEW packages will be installed: autoconf automake autopoint autotools-dev debhelper devhelp devhelp-common dh-apparmor docbook docbook-dsssl docbook-to-man docbook-xml docbook-xsl doxygen evolution-data-server-dev gir1.2-brasero-3.0 gir1.2-caribou-1.0 gir1.2-champlain-0.12 gir1.2-clutter-1.0 gir1.2-clutter-gst-1.0 gir1.2-cogl-1.0 gir1.2-coglpango-1.0 gir1.2-evince-3.0 gir1.2-farstream-0.2 gir1.2-folks-0.6 gir1.2-gck-1 gir1.2-gconf-2.0 gir1.2-gcr-3 gir1.2-gdesktopenums-3.0 gir1.2-gee-0.8 gir1.2-geocodeglib-1.0 gir1.2-gkbd-3.0 gir1.2-gnomedesktop-3.0 gir1.2-gst-plugins-base-0.10 gir1.2-gstreamer-0.10 gir1.2-gtk-2.0 gir1.2-gtkchamplain-0.12 gir1.2-gtkclutter-1.0 gir1.2-gtop-2.0 gir1.2-gucharmap-2.90 gir1.2-gweather-3.0 gir1.2-gxps-0.1 gir1.2-json-1.0 gir1.2-mutter-3.0 gir1.2-nautilus-3.0 gir1.2-nmgtk-1.0 gir1.2-panelapplet-4.0 gir1.2-rest-0.7 gir1.2-rsvg-2.0 gir1.2-telepathyglib-0.12 gir1.2-xkl-1.0 gjs gnome-api-docs gnome-common gnome-core-devel gnome-devel-docs gnome-js-common gnome-platform-devel gobject-introspection graphviz gsettings-desktop-schemas-dev gstreamer1.0-doc gtk-doc-tools intltool itstool jade libarchive-dev libatk-bridge2.0-dev libatk1.0-dev libatk1.0-doc libatkmm-1.6-dev libatspi2.0-dev libbrasero-media3-dev libcairo-script-interpreter2 libcairo2-dev libcairo2-doc libcairomm-1.0-dev libcamel1.2-dev libcanberra-doc libcaribou-common libcaribou-dev libcaribou0 libcdt5 libcgraph6 libchamplain-0.12-0 libchamplain-0.12-dev libchamplain-gtk-0.12-0 libchamplain-gtk-0.12-dev libclutter-1.0-dev libclutter-1.0-doc libclutter-gst-1.0-0 libclutter-gst-dev libclutter-gtk-1.0-dev libclutter-gtk-1.0-doc libcogl-dev libcogl-doc libcogl-pango-dev libcroco3-dev libdbus-1-dev libdbus-glib-1-dev libdconf-dev libdconf-doc libdevhelp-3-2 libdrm-dev libebackend1.2-dev libebook-contacts1.2-dev libebook1.2-dev libecal1.2-dev libedata-book1.2-dev libedata-cal1.2-dev libedataserver1.2-dev libegl1-mesa-dev libencode-locale-perl libevince-dev libexpat1-dev libfarstream-0.2-dev libffi-dev libfile-listing-perl libfolks-dev libfont-afm-perl libfontconfig1-dev libfreetype6-dev libgail-3-dev libgail-3-doc libgail-dev libgail-doc libgbm-dev libgck-1-dev libgconf2-dev libgconf2-doc libgcr-3-dev libgdk-pixbuf2.0-dev libgdk-pixbuf2.0-doc libgee-0.8-dev libgeocode-glib-dev libgeocode-glib0 libgirepository1.0-dev libgjs-dev libgjs0e libgl1-mesa-dev libgles2-mesa-dev libglib2.0-dev libglib2.0-doc libglibmm-2.4-dev libgmime-2.6-dev libgnome-bluetooth-dev libgnome-desktop-3-dev libgnome-keyring-dev libgnome-menu-3-dev libgnomekbd-dev libgstreamer-plugins-base0.10-dev libgstreamer-plugins-base1.0-dev libgstreamer0.10-dev libgstreamer1.0-dev libgtk-3-dev libgtk-3-doc libgtk2.0-dev libgtk2.0-doc libgtkmm-3.0-dev libgtksourceview-3.0-dev libgtksourceview-3.0-doc libgtop2-dev libgucharmap-2-90-dev libgvc6 libgvpr2 libgweather-3-dev libgxps-dev libharfbuzz-dev libharfbuzz-gobject0 libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libical-dev libice-dev libio-html-perl libjavascriptcoregtk-3.0-dev libjson-glib-dev libltdl-dev liblwp-mediatypes-perl liblwp-protocol-https-perl libmail-sendmail-perl libmirclient-dev libmirclient7 libmirclientplatform-mesa libmirprotobuf-dev libmirprotobuf0 libmozjs-24-0 libmozjs-24-bin libmozjs-24-dev libmutter-dev libmutter0c libnautilus-extension-dev libnet-http-perl libnm-glib-dev libnm-gtk-dev libnm-util-dev libnotify-dev libnotify-doc libnspr4-dev libnss3-dev libp11-kit-dev libpanel-applet-4-0 libpanel-applet-4-dev libpanel-applet-4-doc libpango1.0-dev libpango1.0-doc libpangomm-1.4-dev libpathplan4 libpcre3-dev libpcrecpp0 libpeas-dev libpixman-1-dev libpng12-dev libprotobuf-dev libprotobuf-lite8 libpthread-stubs0-dev libpython-dev libpython2.7-dev librest-dev librsvg2-dev libsecret-1-dev libseed-gtk3-0 libseed-gtk3-dev libsigc++-2.0-dev libsigsegv2 libsm-dev libsoup-gnome2.4-dev libsoup2.4-dev libsp1c2 libsqlite3-dev libstartup-notification0-dev libsys-hostname-long-perl libtasn1-3-bin libtasn1-3-dev libtasn1-6-dev libtasn1-bin libtelepathy-farstream-dev libtelepathy-glib-dev libtelepathy-glib-doc libtool libtotem-plparser-dev libudev-dev libudisks2-dev libvala-0.22-0 libvte-2.90-dev libvte-2.90-doc libwacom-dev libwayland-dev libwebkitgtk-3.0-dev libwebkitgtk-common-dev libwnck-3-dev libwww-perl libwww-robotrules-perl libx11-dev libx11-doc libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbcommon-dev libxkbfile-dev libxklavier-dev libxml-parser-perl libxml2-dev libxml2-doc libxml2-utils libxrandr-dev libxrender-dev libxres-dev libxshmfence-dev libxtst-dev libxxf86vm-dev m4 mesa-common-dev mircommon-dev mm-common mutter-common network-manager-dev po-debconf policykit-1-doc python-dev python-gi-dev python-gobject-2-dev python-gobject-dev python-mako python-markupsafe python2.7-dev sgml-data sp valac valac-0.22 valac-0.22-vapi x11proto-composite-dev x11proto-core-dev x11proto-damage-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev x11proto-kb-dev x11proto-randr-dev x11proto-record-dev x11proto-render-dev x11proto-resource-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xorg-sgml-doctools xsltproc xtrans-dev yelp-tools zlib1g-dev The following packages will be upgraded: evince evolution-data-server evolution-data-server-common evolution-data-server-online-accounts gir1.2-ebook-1.2 gir1.2-ebookcontacts-1.2 gir1.2-edataserver-1.2 gir1.2-freedesktop gir1.2-glib-2.0 gir1.2-gnomebluetooth-1.0 gir1.2-gtk-3.0 gir1.2-javascriptcoregtk-3.0 gir1.2-networkmanager-1.0 gir1.2-pango-1.0 gir1.2-webkit-3.0 gir1.2-wnck-3.0 gnome-bluetooth gnome-desktop3-data libarchive13 libcairo-gobject2 libcairo2 libcamel-1.2-45 libclutter-gtk-1.0-0 libdbus-1-3 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libebackend-1.2-7 libebook-1.2-14 libebook-contacts-1.2-0 libecal-1.2-16 libedata-book-1.2-20 libedata-cal-1.2-23 libedataserver-1.2-18 libegl1-mesa libegl1-mesa-drivers libevdocument3-4 libevview3-3 libfreetype6 libgail-3-0 libgail-common libgail18 libgbm1 libgirepository-1.0-1 libgl1-mesa-glx libglapi-mesa libgles2-mesa libglib2.0-0 libglib2.0-bin libgnome-bluetooth11 libgnome-desktop-3-7 libgtk-3-0 libgtk2.0-0 libgtk2.0-bin libgweather-3-6 libharfbuzz-icu0 libharfbuzz0b libjavascriptcoregtk-3.0-0 libnautilus-extension1a libnm-glib4 libnm-gtk-common libnm-gtk0 libnm-util2 libnspr4 libnss3 libnss3-1d libnss3-nssdb libpango-1.0-0 libpango1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpangoxft-1.0-0 libtasn1-6 libudev1 libwayland-egl1-mesa libwebkitgtk-3.0-0 libwebkitgtk-3.0-common libwnck-3-0 libxext6 libxfixes3 libxi6 libxml2 libxrender1 network-manager-gnome python-gi python-gi-cairo python3-gi python3-gi-cairo udev 90 upgraded, 337 newly installed, 0 to remove and 344 not upgraded. Need to get 118 MB of archives. After this operation, 507 MB of additional disk space will be used. Do you want to continue? [Y/n]
查看pkg和gtk版本:
可见gtk的2.x和3.x版本均可用。
编辑和运行测试程序:
/************************************************************************* > File Name: hellogtk.c > Author: Nick > Mail: xjhznick@gmail.com > Created Time: 2015年05月26日 星期二 22时55分11秒 ************************************************************************/ #include <gtk/gtk.h> int main(int argc,char *argv[]) { GtkWidget *window; GtkWidget *label; gtk_init(&argc,&argv); /* create the main, top level, window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* give it the title */ gtk_window_set_title(GTK_WINDOW(window),"Hello World"); /* connect the destroy signal of the window to gtk_main_quit * when the window is about to be destroyed we get a notification and * stop the main GTK+ loop */ g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit),NULL); /* create the "Hello, World" label */ label = gtk_label_new("Hello, World"); /* and insert it into the main window */ gtk_container_add(GTK_CONTAINER(window),label); /* make sure that everything, window and label, are visible */ gtk_widget_show_all(window); /* start the main loop, and let it rest until the application is closed */ gtk_main(); return 0; }
编译命令:
$ gcc -o Helloworld hellogtk.c `pkg-config --cflags --libs gtk+-3.0`
本文出自 “飒飒秋风” 博客,请务必保留此出处http://xjhznick.blog.51cto.com/3608584/1655450
Ubuntu14.04 64Bit 中从源码编译安装Gtk-3.16.3
原文地址:http://xjhznick.blog.51cto.com/3608584/1655450