设为首页 收藏本站
查看: 1281|回复: 0

[经验分享] Mac OS X Lion 10.7.4上安装GTK+心得,兼谈如何解决fink的“could not determine XFree86 version nu

[复制链接]

尚未签到

发表于 2015-12-29 15:42:52 | 显示全部楼层 |阅读模式
  作者:zyl910。
  折腾了好几天,终于在Mac OS X Lion 10.7.4上装好GTK+了。其中走了不少弯路,于是将经验教训总结了一下。


一、系统环境(OS X与XCode)

  操作系统:Mac OS X Lion 10.7.4(11E53)
  编程工具:Xcode 4.4.1(1448),并装好了它的“Command Line Tools”。
  安装过程可参考这些帖子——
在virtualbox上安装Mac OS X Lion 之 配置过程
http://www.crifan.com/install_mac_os_x_lion_on_virtualbox_config_process/
  给VirtualBox上的Mac Lion安装Xcode
http://www.crifan.com/install_xcode_for_mac_on_virtualbox/
  Mac OS X Lion下找不到GCC
http://blog.csdn.net/qinjienj/article/details/7456193
  

二、尝试GTK+官网方法
  对于mac系统,官网上主要是以下这几个页面——
Download for Mac OS X
http://www.gtk.org/download/macos.php
  Building GTK-OSX
https://live.gnome.org/GTK%2B/OSX/Building
  Bundling
https://live.gnome.org/GTK%2B/OSX/Bundling
  
  我按照上述说明装好了jhbuild和gtk-mac-bundler,但后面的就没看懂,不知道怎么装。
  在网上搜索了很久,找不到该方法的安装经验文章。遂放弃。


三、尝试利用homebrew安装

  在网上搜索了一下,发现有人推荐用homebrew安装gtk(http://www.haskell.org/haskellwiki/Gtk2Hs/Mac)。于是决定试试。

3.1 安装homebrew
  homebrew的官网是 http://mxcl.github.com/homebrew/。官网上介绍了homebrew的安装方法,就是在终端上运行下面这条命令——



ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
  
  该命令是ruby脚本。mac下不需要安装ruby解释环境,因为系统自带了。
  安装好后,可以使用下列命令来检查homebrew版本,确认是否安装成功——
brew –v


3.2 尝试安装GTK+

  先检查一下homebrew是否支持GTK+,在终端中输入“brew search gtk”,执行结果如下——



macmatoiMac:~ mac$ brew search gtk
gtk+  gtk-doc  gtkglextmm gtkwave  pygtkglext
gtk+3  gtk-gnutella gtkmm  lablgtk
gtk-chtheme gtkglext gtksourceview pygtk
  
  发现列表中有“gtk+”。于是在终端中输入“brew install gtk+”进行安装——



macmatoiMac:~ mac$ brew install gtk+
==> Installing gtk+ dependency: pkg-config
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-
  
  等了很久,发现还是停在这一行。估计是因为SourceForge被墙了。放弃吧,按Ctrl+C终止。


四、尝试利用fink安装

  又在网络中搜索了很久,发现有人推荐fink(http://blog.sina.com.cn/s/blog_465881ff0100lnjq.html)。于是我决定试试。

4.1 安装fink
  fink的官网是 www.finkproject.org。
  点击国旗切换到中文,点击“下载”链接转到下载页面。
  因为OS X Lion是基于Intel处理器的,于是点击“Fink 0.9.0 二进制安装包 (Intel)”,下载“Fink-0.9.0-Intel-Installer.dmg”。
  下载完成后,根据官网说明进行安装——



2.双击 "Fink-0.9.0-Installer.dmg" 文件装载磁盘映象,然后双击里面 "Fink 0.9.0 Installer.pkg" 程序。接着按照屏幕的提示进行操作。
3.在安装的最后阶段,会打开一个终端程序,pathsetup.command 脚本会被自动运行。在编辑你的 shell 配置文件前,会提示请求你的同意。当脚本运行完毕,关闭终端窗口以后,一切都安装就绪了!
4.如果在此过程中发生了什么错误,你可以尝试重新运行一次安装程序宗卷里面的 pathsetup.command 文件(需要在终端窗口里面运行)。
open /sw/bin/pathsetup.command (这个过程应该对你机器的每个帐号都运行一次:每个用户应该登录到自己的帐号运行一次 pathsetup.command 脚本)。
如果 pathsetup.command 产生了错误信息,请参考文档,尤其是《用户指南》里面的 2.3 “设置你的环境”。
  
  可是在我的电脑上,在Pacifist上点击安装后,进度条跑完后并没有出现终端窗口。
DSC0000.png
  于是我按照说明,打开终端,输入命令,结果报错—— 



macmatoiMac:~ mac$ open /sw/bin/pathsetup.command
The file /sw/bin/pathsetup.command does not exist.
  
  找不到文件?将官网网页切换到英语,发现命令是“/sw/bin/pathsetup.sh”。原来是中文版没有更新。
  于是在终端中输入该命令运行脚本。
  脚本运行完之后。依照官网说明在终端中输入命令,结果报错——



macmatoiMac:bin mac$ fink scanpackages; fink index
-bash: fink: command not found
  
  关闭终端,再打开终端运行命令,还是报告“fink: command not found”。
  关机,重启。打开终端运行命令,这回OK了——



macmatoiMac:~ mac$ fink scanpackages; fink index
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Password:
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Updating the list of locally available binary packages.
Scanning dists/local/main/binary-darwin-i386
Scanning dists/stable/main/binary-darwin-i386
Scanning dists/stable/crypto/binary-darwin-i386
Downloading the indexes of available packages in the binary distribution.
/sw/bin/apt-get-lockwait -q update
Hit http://bindist.finkmirrors.net 10.5/release/main Packages
Hit http://bindist.finkmirrors.net 10.5/release/main Release
Hit http://bindist.finkmirrors.net 10.5/release/crypto Packages
Hit http://bindist.finkmirrors.net 10.5/release/crypto Release
Get:1 http://bindist.finkmirrors.net 10.5/current/main Packages [2261B]
Hit http://bindist.finkmirrors.net 10.5/current/main Release
Get:2 http://bindist.finkmirrors.net 10.5/current/crypto Packages [20B]
Hit http://bindist.finkmirrors.net 10.5/current/crypto Release
Fetched 2281B in 4s (484B/s)
could not determine XFree86 version number
Reading Package Lists...
Building Dependency Tree...
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Failed: It appears that Fink's package database is corrupted. Please run 'fink index -f' to recreate it.
macmatoiMac:~ mac$ fink index
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Failed: It appears that Fink's package database is corrupted. Please run 'fink index -f' to recreate it.
macmatoiMac:~ mac$ fink index -f
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Scanning package description files..........
macmatoiMac:~ mac$ fink index
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Scanning package description files..........
macmatoiMac:~ mac$
  
  中途“fink index”报错,根据提示执行“fink index -f”。


4.2 尝试安装GTK+,遇到问题

  先查一查是否有gtk——



macmatoiMac:bin mac$ fink list gtk*
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Scanning package description files..........
could not determine XFree86 version number
Information about 2545 packages read in 1 seconds.
gtk+             1.2.10-51    The Gimp Toolkit
gtk+-data        1.2.10-51    The Gimp Toolkit
gtk+-shlibs      1.2.10-51    The Gimp Toolkit
gtk+2            2.6.10-1003  The Gimp Toolkit
gtk+2-dev        2.6.10-1003  The Gimp Toolkit
gtk+2-shlibs     2.6.10-1003  The Gimp Toolkit
gtk-doc          1.3-1012     GTK+ - API documentation generator
gtk-engines      0.12-3       Theme plugins for Gtk
gtk2-engines     2.6.10-2     Theme plugins for Gtk
gtkglarea        1.2.3-15     OpenGL widget for GTK+
gtkglarea2       1.99.0-1004  OpenGL widget for GTK+
gtkglarea2-s...  1.99.0-1004  OpenGL widget for GTK+
gtkglext1        1.0.6-1002   OpenGL Extension to GTK
gtkglext1-sh...  1.0.6-1002   OpenGL Extension to GTK
gtkgraph         0.6.2-4      Graphing calculator using Gtk+
gtkhtml          1.0.2-1054   HTML rendering/printing/editing engine
gtkhtml-dev      1.0.2-1054   HTML rendering/printing/editing engine
gtkhtml-shlibs   1.0.2-1054   HTML rendering/printing/editing engine
gtkhtml1.1       1.1.7-1014   HTML rendering/printing/editing engine
gtkhtml1.1-dev   1.1.7-1014   HTML rendering/printing/editing engine
gtkhtml1.1-s...  1.1.7-1014   HTML rendering/printing/editing engine
gtkmm2           2.2.12-1002  C++ interface for the gtk+2 library
gtkmm2-dev       2.2.12-1002  C++ interface for the gtk+2 library
gtkmm2-shlibs    2.2.12-1002  C++ interface for the gtk+2 library
gtksourceview    1.0.1-1007   Source code viewing tool
gtksourcevie...  1.0.1-1007   Headers and libraries for developing with...
gtksourcevie...  1.0.1-1007   Shared libraries for gtksourceview
gtkspell2        2.0.4-1005   Highlight misspelled words as you type
gtkspell2-dev    2.0.4-1005   Highlight misspelled words as you type
gtkspell2-sh...  2.0.4-1005   Highlight misspelled words as you type
  
  
  发现有“gtk+2”,于是开始安装——



macmatoiMac:bin mac$ fink install gtk+2
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Scanning package description files..........
could not determine XFree86 version number
Information about 2545 packages read in 2 seconds.
could not determine XFree86 version number
fink needs help picking an alternative to satisfy a virtual dependency. The
candidates:
(1)    system-xfree86-manual-install: Manually installed X11 components
(2)    system-xfree86: [virtual package representing Apple's install of X11]

Pick one: [1] 1
The following package will be installed or updated:
gtk+2
The following 10 additional packages will be installed:
atk1-shlibs glib2-shlibs gtk+2-shlibs libjpeg-shlibs libpng3-shlibs
libtiff-shlibs pango1-xft2 pango1-xft2-shlibs system-xfree86-manual-install
xdg-base
Do you want to continue? [Y/n] y
/sw/bin/apt-get-lockwait -q --ignore-breakage --download-only install atk1-shlibs=1.12.4-2 glib2-shlibs=2.12.0-103 gtk+2=2.6.10-1003 gtk+2-shlibs=2.6.10-1003 libjpeg-shlibs=6b-17 libpng3-shlibs=1:1.2.29-1 libtiff-shlibs=3.8.2-1002 pango1-xft2=1.10.1-1003 pango1-xft2-shlibs=1.10.1-1003 xdg-base=0.6-2
could not determine XFree86 version number
Reading Package Lists...
Building Dependency Tree...
The following NEW packages will be installed:
atk1-shlibs glib2-shlibs gtk+2 gtk+2-shlibs libjpeg-shlibs libpng3-shlibs
libtiff-shlibs pango1-xft2 pango1-xft2-shlibs xdg-base
0 packages upgraded, 10 newly installed, 0 to remove and 2  not upgraded.
Need to get 7211kB of archives. After unpacking 23.1MB will be used.
Get:1 http://bindist.finkmirrors.net 10.5/release/main xdg-base 0.6-2 [1232B]
Get:2 http://bindist.finkmirrors.net 10.5/release/main glib2-shlibs 2.12.0-103 [863kB]
Get:3 http://bindist.finkmirrors.net 10.5/release/main atk1-shlibs 1.12.4-2 [231kB]
Get:4 http://bindist.finkmirrors.net 10.5/release/main libjpeg-shlibs 6b-17 [75.3kB]
Get:5 http://bindist.finkmirrors.net 10.5/release/main libpng3-shlibs 1:1.2.29-1 [156kB]
Get:6 http://bindist.finkmirrors.net 10.5/release/main libtiff-shlibs 3.8.2-1002 [127kB]
Get:7 http://bindist.finkmirrors.net 10.5/release/main pango1-xft2-shlibs 1.10.1-1003 [301kB]
Get:8 http://bindist.finkmirrors.net 10.5/release/main gtk+2-shlibs 2.6.10-1003 [2158kB]
Get:9 http://bindist.finkmirrors.net 10.5/release/main pango1-xft2 1.10.1-1003 [29.1kB]
Get:10 http://bindist.finkmirrors.net 10.5/release/main gtk+2 2.6.10-1003 [3269kB]
Fetched 7211kB in 39s (183kB/s)
Download complete and in download only mode
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/libjpeg-shlibs_6b-17_darwin-i386.deb
could not determine XFree86 version number
Selecting previously deselected package libjpeg-shlibs.
(Reading database ... 4102 files and directories currently installed.)
Unpacking libjpeg-shlibs (from .../libjpeg-shlibs_6b-17_darwin-i386.deb) ...
Setting up libjpeg-shlibs (6b-17) ...
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/libpng3-shlibs_1%3a1.2.29-1_darwin-i386.deb
could not determine XFree86 version number
Selecting previously deselected package libpng3-shlibs.
(Reading database ... 4106 files and directories currently installed.)
Unpacking libpng3-shlibs (from .../libpng3-shlibs_1%3a1.2.29-1_darwin-i386.deb) ...
Setting up libpng3-shlibs (1.2.29-1) ...
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/libtiff-shlibs_3.8.2-1002_darwin-i386.deb
could not determine XFree86 version number
Selecting previously deselected package libtiff-shlibs.
(Reading database ... 4114 files and directories currently installed.)
Unpacking libtiff-shlibs (from .../libtiff-shlibs_3.8.2-1002_darwin-i386.deb) ...
Setting up libtiff-shlibs (3.8.2-1002) ...
Setting runtime build-lock...
dpkg-deb -b /sw/src/fink.build/root-fink-buildlock-system-xfree86-manual-install-0-0 /sw/src/fink.build
dpkg-deb: building package `fink-buildlock-system-xfree86-manual-install-0-0' in `/sw/src/fink.build/fink-buildlock-system-xfree86-manual-install-0-0_2012.09.10-17.54.39_darwin-i386.deb'.
Installing build-lock package...
/sw/bin/dpkg-lockwait -i /sw/src/fink.build/fink-buildlock-system-xfree86-manual-install-0-0_2012.09.10-17.54.39_darwin-i386.deb
could not determine XFree86 version number
Selecting previously deselected package fink-buildlock-system-xfree86-manual-install-0-0.
(Reading database ... 4119 files and directories currently installed.)
Unpacking fink-buildlock-system-xfree86-manual-install-0-0 (from .../fink-buildlock-system-xfree86-manual-install-0-0_2012.09.10-17.54.39_darwin-i386.deb) ...
Setting up fink-buildlock-system-xfree86-manual-install-0-0 (2012.09.10-17.54.39) ...
Use of uninitialized value $darwin_osx in numeric eq (==) at /sw/lib/perl5/Fink/Services.pm line 1404.
Use of uninitialized value $darwin_osx in concatenation (.) or string at /sw/lib/perl5/Fink/Services.pm line 1404.
Argument "10.7 does not match the expected value of . Please run `..." isn't numeric in exit at /sw/lib/perl5/Fink/Services.pm line 1404.
Removing runtime build-lock...
Removing build-lock package...
/sw/bin/dpkg-lockwait -r fink-buildlock-system-xfree86-manual-install-0-0
could not determine XFree86 version number
(Reading database ... 4120 files and directories currently installed.)
Removing fink-buildlock-system-xfree86-manual-install-0-0 ...
  
  
  似乎没有装好。于是再运行了几次“fink install gtk+2”,结果还是输出类似信息。
  观察了一下输出信息,似乎问题是出在检测不到XFree86版本——
could not determine XFree86 version number


五、解决fink的“could not determine XFree86 version number”错误


5.1 解决办法
  在网上搜索了很久,尝试了不少办法,最后发现这个帖子的办法有效——
Interaction issue between XQuartz-2.6.0 and fink on Leopard.
http://finkers.wordpress.com/2011/02/06/375/
  其大意是——在超级权限下编辑“/sw/lib/perl5/Fink/VirtPackage.pm”,找到这一行(大概是1736行)——
if (open (XBIN, "$xdir/bin/$binary -version -iokit 2>\&1 |")) {
  将该行改为——
if (open (XBIN, "$xdir/bin/$binary -version 2>\&1 |")) {
  
5.2 具体操作
  用文本编辑器打开“/sw/lib/perl5/Fink/VirtPackage.pm”,搜索“iokit”,找到了那一行——
DSC0001.png
  因为不是超级权限,不能保存。于是我在Finder中将“/sw/lib/perl5/Fink/VirtPackage.pm”复制到home目录。
  然后打开终端,运行chmod命令修改文件权限——



macmatoiMac:~ mac$ ls -l VirtPackage.pm
-rw-r--r--  1 mac  staff  55588  6 27  2008 VirtPackage.pm
macmatoiMac:~ mac$ chmod go+w VirtPackage.pm
  
  在文本编辑器中打开home目录下的VirtPackage.pm,删除“-iokit”,并保存。
  现在VirtPackage.pm文件已经改好了,用chmod命令将文件权限改回来,再用sudo执行cp命令复制文件——



macmatoiMac:~ mac$ chmod go-w VirtPackage.pm
macmatoiMac:~ mac$ ls -l VirtPackage.pm
-rw-r--r--@ 1 mac  staff  55581  9 13 00:07 VirtPackage.pm
macmatoiMac:~ mac$ sudo cp VirtPackage.pm /sw/lib/perl5/Fink
Password:
macmatoiMac:~ mac$
DSC0002.png


六、装好GTK+2,并编译程序


6.1 直到能运行gtk-demo
  现在再运行“fink install gtk+2”,发现能成功装上,但好像装的是运行环境,而不是开发版。于是使用“fink list”命令检索包列表,依次安装了这些东西——



fink install gtk+2
fink install gtk+2-dev
fink install glib2-dev
fink install pkgconfig
  
  详细操作过程——


DSC0003.gif DSC0004.gif 操作过程


macmatoiMac:~ mac$ fink install gtk+2
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 2 seconds.
The following package will be installed or updated:
gtk+2
The following 6 additional packages will be installed:
atk1-shlibs glib2-shlibs gtk+2-shlibs pango1-xft2 pango1-xft2-shlibs xdg-base
Do you want to continue? [Y/n] Y
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/xdg-base_0.6-2_darwin-i386.deb
Selecting previously deselected package xdg-base.
(Reading database ... 4119 files and directories currently installed.)
Unpacking xdg-base (from .../xdg-base_0.6-2_darwin-i386.deb) ...
Setting up xdg-base (0.6-2) ...
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/glib2-shlibs_2.12.0-103_darwin-i386.deb
Selecting previously deselected package glib2-shlibs.
(Reading database ... 4121 files and directories currently installed.)
Unpacking glib2-shlibs (from .../glib2-shlibs_2.12.0-103_darwin-i386.deb) ...
Setting up glib2-shlibs (2.12.0-103) ...
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/pango1-xft2_1.10.1-1003_darwin-i386.deb /sw/var/cache/apt/archives/pango1-xft2-shlibs_1.10.1-1003_darwin-i386.deb
Selecting previously deselected package pango1-xft2.
(Reading database ... 4299 files and directories currently installed.)
Unpacking pango1-xft2 (from .../pango1-xft2_1.10.1-1003_darwin-i386.deb) ...
Selecting previously deselected package pango1-xft2-shlibs.
Unpacking pango1-xft2-shlibs (from .../pango1-xft2-shlibs_1.10.1-1003_darwin-i386.deb) ...
Setting up pango1-xft2-shlibs (1.10.1-1003) ...
Setting up pango1-xft2 (1.10.1-1003) ...
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/atk1-shlibs_1.12.4-2_darwin-i386.deb
Selecting previously deselected package atk1-shlibs.
(Reading database ... 4359 files and directories currently installed.)
Unpacking atk1-shlibs (from .../atk1-shlibs_1.12.4-2_darwin-i386.deb) ...
Setting up atk1-shlibs (1.12.4-2) ...
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/gtk+2_2.6.10-1003_darwin-i386.deb /sw/var/cache/apt/archives/gtk+2-shlibs_2.6.10-1003_darwin-i386.deb
Selecting previously deselected package gtk+2.
(Reading database ... 4469 files and directories currently installed.)
Unpacking gtk+2 (from .../gtk+2_2.6.10-1003_darwin-i386.deb) ...
Selecting previously deselected package gtk+2-shlibs.
Unpacking gtk+2-shlibs (from .../gtk+2-shlibs_2.6.10-1003_darwin-i386.deb) ...
Setting up gtk+2-shlibs (2.6.10-1003) ...
Setting up gtk+2 (2.6.10-1003) ...
macmatoiMac:~ mac$ fink list gtk+
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 2 seconds.
gtk+             1.2.10-51    The Gimp Toolkit
gtk+-data        1.2.10-51    The Gimp Toolkit
gtk+-shlibs      1.2.10-51    The Gimp Toolkit
i   gtk+2            2.6.10-1003  The Gimp Toolkit
gtk+2-dev        2.6.10-1003  The Gimp Toolkit
i   gtk+2-shlibs     2.6.10-1003  The Gimp Toolkit
macmatoiMac:~ mac$ fink install gtk+2dev
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 0 seconds.
Failed: no package found for specification 'gtk+2dev'!
macmatoiMac:~ mac$ fink install gtk+2-dev
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 1 seconds.
The following package will be installed or updated:
gtk+2-dev
/sw/bin/apt-get-lockwait -q --ignore-breakage --download-only install gtk+2-dev=2.6.10-1003
Reading Package Lists...
Building Dependency Tree...
The following NEW packages will be installed:
gtk+2-dev
0 packages upgraded, 1 newly installed, 0 to remove and 2  not upgraded.
Need to get 4773kB of archives. After unpacking 22.5MB will be used.
Get:1 http://bindist.finkmirrors.net 10.5/release/main gtk+2-dev 2.6.10-1003 [4773kB]
Fetched 4773kB in 20s (231kB/s)
Download complete and in download only mode
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/gtk+2-dev_2.6.10-1003_darwin-i386.deb
Selecting previously deselected package gtk+2-dev.
(Reading database ... 4769 files and directories currently installed.)
Unpacking gtk+2-dev (from .../gtk+2-dev_2.6.10-1003_darwin-i386.deb) ...
Setting up gtk+2-dev (2.6.10-1003) ...
macmatoiMac:~ mac$ fink list gtk+
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 0 seconds.
gtk+             1.2.10-51    The Gimp Toolkit
gtk+-data        1.2.10-51    The Gimp Toolkit
gtk+-shlibs      1.2.10-51    The Gimp Toolkit
i   gtk+2            2.6.10-1003  The Gimp Toolkit
i   gtk+2-dev        2.6.10-1003  The Gimp Toolkit
i   gtk+2-shlibs     2.6.10-1003  The Gimp Toolkit
macmatoiMac:~ mac$ fink list pkg-config
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 1 seconds.
macmatoiMac:~ mac$ fink list pkg-config*
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 0 seconds.
macmatoiMac:~ mac$ fink list pkgconfig*
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 1 seconds.
pkgconfig        0.21-1       Manager for library compile/link flags
macmatoiMac:~ mac$ fink list glib*
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 1 seconds.
glib             1.2.10-50    Common C routines used by Gtk+ and other ...
glib-shlibs      1.2.10-50    Common C routines used by Gtk+ and other ...
glib2            2.12.0-103   Handy library of utility functions
glib2-dev        2.12.0-103   Handy library of utility functions
i   glib2-shlibs     2.12.0-103   Handy library of utility functions
glibwww          0.2-14       Set of register/unregister functions
glibwww-shlibs   0.2-14       Set of register/unregister functions
macmatoiMac:~ mac$ fink install glib2-dev
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Password:
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 0 seconds.
The following package will be installed or updated:
glib2-dev
/sw/bin/apt-get-lockwait -q --ignore-breakage --download-only install glib2-dev=2.12.0-103
Reading Package Lists...
Building Dependency Tree...
The following NEW packages will be installed:
glib2-dev
0 packages upgraded, 1 newly installed, 0 to remove and 2  not upgraded.
Need to get 1540kB of archives. After unpacking 9032kB will be used.
Get:1 http://bindist.finkmirrors.net 10.5/release/main glib2-dev 2.12.0-103 [1540kB]
Fetched 1540kB in 7s (209kB/s)
Download complete and in download only mode
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/glib2-dev_2.12.0-103_darwin-i386.deb
Selecting previously deselected package glib2-dev.
(Reading database ... 5592 files and directories currently installed.)
Unpacking glib2-dev (from .../glib2-dev_2.12.0-103_darwin-i386.deb) ...
Setting up glib2-dev (2.12.0-103) ...
macmatoiMac:~ mac$ fink install pkgconfig
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 1 seconds.
The following package will be installed or updated:
pkgconfig
The following additional package will be installed:
glib-shlibs
Do you want to continue? [Y/n] Y
/sw/bin/apt-get-lockwait -q --ignore-breakage --download-only install glib-shlibs=1.2.10-50 pkgconfig=0.21-1
Reading Package Lists...
Building Dependency Tree...
The following NEW packages will be installed:
glib-shlibs pkgconfig
0 packages upgraded, 2 newly installed, 0 to remove and 2  not upgraded.
Need to get 158kB of archives. After unpacking 479kB will be used.
Get:1 http://bindist.finkmirrors.net 10.5/release/main glib-shlibs 1.2.10-50 [98.7kB]
Get:2 http://bindist.finkmirrors.net 10.5/release/main pkgconfig 0.21-1 [58.9kB]
Fetched 158kB in 3s (46.5kB/s)
Download complete and in download only mode
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/glib-shlibs_1.2.10-50_darwin-i386.deb
Selecting previously deselected package glib-shlibs.
(Reading database ... 5887 files and directories currently installed.)
Unpacking glib-shlibs (from .../glib-shlibs_1.2.10-50_darwin-i386.deb) ...
Setting up glib-shlibs (1.2.10-50) ...
Reading buildlock packages...
/sw/bin/dpkg-lockwait -i /sw/var/cache/apt/archives/pkgconfig_0.21-1_darwin-i386.deb
Selecting previously deselected package pkgconfig.
(Reading database ... 5898 files and directories currently installed.)
Unpacking pkgconfig (from .../pkgconfig_0.21-1_darwin-i386.deb) ...
Setting up pkgconfig (0.21-1) ...
macmatoiMac:~ mac$ gtk-demo
  
  
  这时运行gtk-demo,发现能成功打开GTK的demo——
DSC0005.png


6.2 直到能运行pkg-config --cflags --libs gtk+-2.0

  刚才似乎已经将pkgconfig装好了,于是我执行几条命令测试一下——



macmatoiMac:~ mac$ pkg-config --cflags --libs gl
-I/usr/X11/include  -L/usr/X11/lib -lGL  
macmatoiMac:~ mac$ pkg-config --cflags --libs gtk+-2.0
Package pangoxft was not found in the pkg-config search path.
Perhaps you should add the directory containing `pangoxft.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pangoxft', required by 'GDK', not found
  
  发现gl库成功了,而gtk+-2.0库失败了。
  最开始怀疑是$PKG_CONFIG_PATH路径配置问题,但配置后还是不行——



macmatoiMac:~ mac$ echo $PKG_CONFIG_PATH
macmatoiMac:~ mac$ PKG_CONFIG_PATH=/sw/lib/pkgconfig:$PKG_CONFIG_PATH
macmatoiMac:~ mac$ echo $PKG_CONFIG_PATH
/sw/lib/pkgconfig:
macmatoiMac:~ mac$ pkg-config --cflags --libs gtk+-2.0
Package pangoxft was not found in the pkg-config search path.
Perhaps you should add the directory containing `pangoxft.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pangoxft', required by 'GDK', not found
  
  于是怀疑是缺少pangoxft,执行“fink list pangoxft*”。但找不到——



macmatoiMac:~ mac$ fink list pangoxft*
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 2 seconds.
macmatoiMac:~
  
  然后再查查gdk——



macmatoiMac:~ mac$ fink list gdk*
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 0 seconds.
gdk-pixbuf       0.22.0-13    Image loading and manipulation library
gdk-pixbuf-s...  0.22.0-13    Image loading and manipulation library
  
  发现有gdk-pixbuf,于是执行命令“fink install gdk-pixbuf”进行安装。
  装好gdk-pixbuf后,执行“pkg-config --cflags --libs gtk+-2.0”,结果还是报错——



macmatoiMac:~ mac$ pkg-config --cflags --libs gtk+-2.0
Package pangoxft was not found in the pkg-config search path.
Perhaps you should add the directory containing `pangoxft.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pangoxft', required by 'GDK', not found
  
  想起GTK+中有一个库叫“pango”,是不是它呢——



macmatoiMac:~ mac$ fink list pango*
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 1 seconds.
pango1           1.2.1-25     I18N text handling system convinience pac...
pango1-dev       1.2.1-25     I18N text handling system convinience pac...
pango1-shlibs    1.2.1-25     I18N text handling system convinience pac...
i   pango1-xft2      1.10.1-1003  GTK+ - i18n libs (for XFree86 >= 4.3)
pango1-xft2-dev  1.10.1-1003  GTK+ - i18n text development headers and ...
pango1-xft2-...  1.10.1-1103  GTK+ - i18n libs (for freetype >= 2.1.9)
pango1-xft2-...  1.10.1-1103  GTK+ - i18n text development headers and ...
pango1-xft2-...  1.10.1-1103  GTK+ - i18n text shared libraries (for fr...
i   pango1-xft2-...  1.10.1-1003  GTK+ - i18n text shared libraries (for XF...
  
  发现有pango1,于是执行命令执行“fink install pango1-dev”进行安装。
  装好pango1-dev后,执行“pkg-config --cflags --libs gtk+-2.0”,又有报错,但内容不同——



macmatoiMac:~ mac$ pkg-config --cflags --libs gtk+-2.0
Package atk was not found in the pkg-config search path.
Perhaps you should add the directory containing `atk.pc'
to the PKG_CONFIG_PATH environment variable
Package 'atk', required by 'GTK+', not found
  
  根据前面的经验,查找atk,并安装atk1——



macmatoiMac:~ mac$ fink list atk*
UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27
Information about 2548 packages read in 1 seconds.
atk1             1.12.4-2     Accessability Toolkit
i   atk1-shlibs      1.12.4-2     Accessability Toolkit
macmatoiMac:~ mac$ fink install atk1
……
  
  装好atk1后,执行“pkg-config --cflags --libs gtk+-2.0”,终于正确输出了——



macmatoiMac:~ mac$ pkg-config --cflags --libs gtk+-2.0
-I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include -I/sw/include/pango-1.0 -I/usr/X11/include -I/usr/X11/include/freetype2 -I/sw/include/gtk-2.0 -I/sw/include/atk-1.0 -I/sw/lib/gtk-2.0/include  -Wl,-framework,CoreServices,-framework,ApplicationServices -L/sw/lib -L/usr/X11/lib -L/usr/X11R6/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -lXrandr -lXinerama -lXext -lXfixes -lXcursor -latk-1.0 -lgdk_pixbuf-2.0 -lpangoxft-1.0 -lXft -lXrender -lpangox-1.0 -lX11 -lpangoft2-1.0 -lfontconfig -lfreetype -lz -lpango-1.0 -lm -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -liconv
  
  


6.3 编译GTK+程序

  写一个GTK+的简单的测试程序(testgtk.c),将它放在home目录。代码如下——



#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
GtkWidget *window;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* quit*/ g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"Hello GTK+!");
gtk_widget_show(window);
gtk_main ();
return 0;
}
  
  在终端上执行“gcc testgtk.c -o testgtk `pkg-config --cflags --libs gtk+-2.0`”开始编译,结果报错——



macmatoiMac:~ mac$ gcc testgtk.c -o testgtk `pkg-config --cflags --libs gtk+-2.0`
ld: warning: ignoring file /sw/lib/libgtk-x11-2.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libgtk-x11-2.0.dylib
ld: warning: ignoring file /sw/lib/libgdk-x11-2.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libgdk-x11-2.0.dylib
ld: warning: ignoring file /sw/lib/libatk-1.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libatk-1.0.dylib
ld: warning: ignoring file /sw/lib/libgdk_pixbuf-2.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libgdk_pixbuf-2.0.dylib
ld: warning: ignoring file /sw/lib/libpangoxft-1.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libpangoxft-1.0.dylib
ld: warning: ignoring file /sw/lib/libpangox-1.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libpangox-1.0.dylib
ld: warning: ignoring file /sw/lib/libpangoft2-1.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libpangoft2-1.0.dylib
ld: warning: ignoring file /sw/lib/libpango-1.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libpango-1.0.dylib
ld: warning: ignoring file /sw/lib/libgobject-2.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libgobject-2.0.dylib
ld: warning: ignoring file /sw/lib/libgmodule-2.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libgmodule-2.0.dylib
ld: warning: ignoring file /sw/lib/libintl.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libintl.dylib
ld: warning: ignoring file /sw/lib/libiconv.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libiconv.dylib
ld: warning: ignoring file /sw/lib/libglib-2.0.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /sw/lib/libglib-2.0.dylib
Undefined symbols for architecture x86_64:
"_g_signal_connect_data", referenced from:
_main in ccysPCRa.o
"_g_type_check_instance_cast", referenced from:
_main in ccysPCRa.o
"_gtk_init", referenced from:
_main in ccysPCRa.o
"_gtk_main", referenced from:
_main in ccysPCRa.o
"_gtk_main_quit", referenced from:
_main in ccysPCRa.o
"_gtk_widget_show", referenced from:
_main in ccysPCRa.o
"_gtk_window_get_type", referenced from:
_main in ccysPCRa.o
"_gtk_window_new", referenced from:
_main in ccysPCRa.o
"_gtk_window_set_title", referenced from:
_main in ccysPCRa.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
  
  看到“x86_64”,想到OS X Lion是64位系统,而fink安装的GTK+很可能是32位。
  于是给gcc加上“-m32”参数,成功通过编译,并能正常运行——



macmatoiMac:~ mac$ gcc -m32 testgtk.c -o testgtk `pkg-config --cflags --libs gtk+-2.0`
macmatoiMac:~ mac$ file testgtk
testgtk: Mach-O executable i386
macmatoiMac:~ mac$ ./testgtk
DSC0006.png
  (完)

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-158093-1-1.html 上篇帖子: Mac系统升级至OS X Mavericks后Genymotion出现的问题及解决方法 下篇帖子: Adobe CC update (Windows/Mac OS) 独立升级包下载
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表