操作系统: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
对于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安装gtk(http://www.haskell.org/haskellwiki/Gtk2Hs/Mac)。于是决定试试。
homebrew的官网是 http://mxcl.github.com/homebrew/。官网上介绍了homebrew的安装方法,就是在终端上运行下面这条命令——
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
该命令是ruby脚本。mac下不需要安装ruby解释环境,因为系统自带了。
安装好后,可以使用下列命令来检查homebrew版本,确认是否安装成功——
brew –v
先检查一下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(http://blog.sina.com.cn/s/blog_465881ff0100lnjq.html)。于是我决定试试。
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上点击安装后,进度条跑完后并没有出现终端窗口。
于是我按照说明,打开终端,输入命令,结果报错——
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 27Password: UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27Updating 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 PackagesHit http://bindist.finkmirrors.net 10.5/release/main ReleaseHit http://bindist.finkmirrors.net 10.5/release/crypto PackagesHit http://bindist.finkmirrors.net 10.5/release/crypto ReleaseGet:1 http://bindist.finkmirrors.net 10.5/current/main Packages [2261B]Hit http://bindist.finkmirrors.net 10.5/current/main ReleaseGet:2 http://bindist.finkmirrors.net 10.5/current/crypto Packages [20B]Hit http://bindist.finkmirrors.net 10.5/current/crypto ReleaseFetched 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 27UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27Failed: 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 27UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27Failed: 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 27UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27Scanning 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 27UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27Scanning package description files.......... macmatoiMac:~ mac$
中途“fink index”报错,根据提示执行“fink index -f”。
先查一查是否有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 27Scanning 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+2UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27UNIVERSAL->import is deprecated and will be removed in a future perl at /sw/lib/perl5/Fink/Checksum.pm line 27Scanning 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] 1The following package will be installed or updated: gtk+2The 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-2could 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-0could 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
在网上搜索了很久,尝试了不少办法,最后发现这个帖子的办法有效——
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”,找到了那一行——
因为不是超级权限,不能保存。于是我在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$
现在再运行“fink install gtk+2”,发现能成功装上,但好像装的是运行环境,而不是开发版。于是使用“fink list”命令检索包列表,依次安装了这些东西——
fink install gtk+2fink install gtk+2-dev fink install glib2-dev fink install pkgconfig
详细操作过程——
操作过程
这时运行gtk-demo,发现能成功打开GTK的demo——
刚才似乎已经将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.0Package 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.0Package 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 27Information 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 27Information 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.0Package 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 27Information 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.0Package 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 27Information 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
写一个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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.dylibld: 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.old: 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
(完)