新装 Leopard 安装开发环境全记录

前期工作

安装光盘里的 Xcode,或者下载 iPhone SDK,2.1G,包括了最新的 Xcode 和 iPhone SDK。

安装好后会有 apache-2.2.6 / php-5.2.5 / ruby-1.8.6 / rails-1.2.6 / python-2.5.1 / java-1.5.0_13 / sqlite-3.4.0 …… gcc 会有2个版本:4.0.14.2.1,默认 /usr/bin/gcc 软连到 gcc-4.0,我们先让默认的 gcc 改用 4.2(2007年1月就 release 了,Changelog
[code]
cd /usr/bin
sudo unlink gcc
sudo ln -s gcc-4.2 gcc
[/code]

设置全局编译参数,编辑 /etc/profile,加上下面的全局变量,保存后重启终端
[code]
export MACOSX_DEPLOYMENT_TARGET=10.5
export ARCHFLAGS=’-arch x86_64′
export CFLAGS=’-arch x86_64 -O3 -pipe’
export CXXFLAGS=$CFLAGS
export LDFLAGS=’-arch x86_64 -bind_at_load’
[/code]

如果需要编译兼容 i386、ppc、ppc64 版本的(编译出来的文件会增大不少),只要加上相应的 -arch 即可
[code]
export CFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -O3 -pipe”
export CXXFLAGS=$CFLAGS
export LDFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load”
[/code]

如果需要编译针对 CPU 优化的,Apple 全系列已经升级到 Intel Core Duo,所以可以加上以下参数
[code]
CHOST=”x86_64-pc-linux-gnu”
CFLAGS=”-march=nocona -O2 -pipe”
CXXFLAGS=”${CFLAGS}”
[/code]
-O 使用 O3,其他详见 http://www.gentoo-wiki.com/Safe_Cflags

因此我自己编译的最终参数是
[code]
export MACOSX_DEPLOYMENT_TARGET=10.5
export ARCHFLAGS=’-arch x86_64′
export CFLAGS=’-arch x86_64 -march=nocona -pipe -O3 -pipe’
export CXXFLAGS=$CFLAGS
export LDFLAGS=’-arch x86_64 -bind_at_load’
[/code]

Java

虽然 Apple 总算在 2008年2月 放出了 JDK6 Preview,但是问题还是非常多。我们还是用 BSD 的一个移植版本 Soylatte,直接下载 64-bit JDK for Mac OS X 10.5: soylatte16-amd64-1.0.2.tar.bz2 (Username: ‘jrl’,Password: ‘I am a Licensee in good standing’)
解压后放到 /usr/local/soylatte16-amd64,软连 /usr/local/java 到这个目录:
[code]
cd /usr/local; sudo ln -s soylatte16-amd64 java
cd /System/Library/Frameworks/JavaVM.framework/Versions/; sudo mkdir soylatte16-amd64
cd soylatte16-amd64; sudo ln -s /usr/local/java Home; sudo ln -s ./Home/bin ./Commands
cd ../A; sudo mv Commands Commands.bak; sudo ln -s ../CurrentJDK/Commands ./
cd ..; sudo unlink CurrentJDK; sudo ln -s soylatte16-amd64 CurrentJDK
java -version
[/code]
显示如下,Java 就算搞定了
[code]
java version “1.6.0_03-p3”
Java(TM) SE Runtime Environment (build 1.6.0_03-p3-landonf_03_feb_2008_01_32-b00)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-p3-landonf_03_feb_2008_01_32-b00, mixed mode)
[/code]

基本库和命令

libtool
[code]
curl http://ftp.gnu.org/gnu/libtool/libtool-1.5.26.tar.gz > libtool-1.5.26.tar.gz
tar xzf libtool-1.5.26.tar.gz
cd libtool-1.5.26
./configure
make
sudo make install
[/code]

zlib
[code]
curl http://www.zlib.net/zlib-1.2.3.tar.gz > zlib-1.2.3.tar.gz
tar xzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
sudo make install
[/code]

openssl/libssl
[code]
curl http://www.openssl.org/source/openssl-0.9.8g.tar.gz > openssl-0.9.8g.tar.gz
tar xzf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config –prefix=/usr/local –openssldir=/openssl threads zlib-dynamic
vi Makefile
# OPTIONS 里去掉 no-sse2 来开启 CPU 的 SSE2 指令集支持
# CFLAG 里 -arch i386 改为 -arch x86_64
# SHARED_LDFLAGS 同上
make
sudo make install
cd /usr/local/bin
sudo ln -s ../openssl/bin/* ./
[/code]

wget
[code]
curl http://ftp.gnu.org/gnu/wget/wget-1.11.tar.bz2 > wget-1.11.tar.bz2
tar xjf wget-1.11.tar.bz2
cd wget-1.11.tar.bz2
./configure –with-libssl-prefix=/usr/local/openssl
make
sudo make install
[/code]

libpng
[code]
wget http://downloads.sourceforge.net/libpng/lpng1225.tar.bz2 -O libpng-1.2.25.tar.bz2
tar xjf libpng-1.2.25.tar.bz2
cd libpng-1.2.25
./configure
make
sudo make install
[/code]

libjpeg
[code]
wget http://freshmeat.net/redir/libjpeg/5665/url_tgz/jpegsrc.v6b.tar.gz
tar xzf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure –enable-shared –enable-static
make
sudo mkdir -p /usr/local/man/man1
sudo make install -lib
[/code]

freetype
[code]
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz
tar xzf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure
make
sudo make install
[/code]

fontconfig
[code]
wget http://fontconfig.org/release/fontconfig-2.5.91.tar.gz
tar xzf fontconfig-2.5.91.tar.gz
cd fontconfig-2.5.91
./configure –prefix=/usr/local –with-zlib –with-jpeg –with-png –with-freetype –disable-dependency-tracking
make
sudo make install
[/code]

gd2
[code]
wget http://www.libgd.org/releases/gd-2.0.35.tar.bz2
tar xjf gd-2.0.35.tar.bz2
cd gd-2.0.35
./configure –with-fontconfig=/usr/local/bin –disable-dependency-tracking
make
sudo make install
[/code]

ImageMagick
[code]
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.3.9-7.tar.bz2
tar xjf ImageMagick-6.3.9-7.tar.bz2
cd ImageMagick-6.3.9
./configure –with-fontconfig
make
sudo make install
[/code]

mysql
[code]
wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51a.tar.gz/from/http://mirror.services.wisc.edu/mysql/
tar xzf mysql-5.0.51a.tar.gz
cd mysql-5.0.51a
./configure –with-mysql-user=mysql –with-mysql-group=mysql –with-innodb –with-archive-storage-engine –with-ndbcluster –with-zlib-dir=/usr/local –with-pthread –with-extra-charsets=utf8 –disable-dependency-tracking
make
sudo make install
[/code]

neon
[code]
wget http://www.webdav.org/neon/neon-0.25.5.tar.gz
tar xzf neon-0.25.5.tar.gz
cd neon-0.25.5
./configure –with-ssl=openssl
make
sudo make install
[/code]

Berkeley DB
[code]
# 为了让 subversion-1.4.6 使用,只能用 db-4.4 版本的
wget http://download.oracle.com/berkeley-db/db-4.4.20.tar.gz
tar xzf db-4.4.20.tar.gz
cd db-4.4.20/build_unix
make
sudo make install
cd /usr/local/; sudo ln -s BerkeleyDB.4.4 bdb
[/code]

subversion
[code]
wget http://apache.mirror.phpchina.com/httpd/httpd-2.2.8.tar.bz2
tar xjf httpd-2.2.8.tar.bz2
wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.bz2
tar xjf subversion-1.4.6.tar.bz2
cd subversion-1.4.6
cp -r ../httpd-2.2.8/srclib/apr* ./
./configure –with-apxs=/usr/sbin/apxs –with-berkeley-db=/usr/local/bdb –with-ssl
make
sudo make install
[/code]

libevent
[code]
wget http://www.monkey.org/~provos/libevent-1.4.2-rc.tar.gz
tar xzf libevent-1.4.2-rc.tar.gz
cd libevent-1.4.2-rc
./configure
make
sudo make install
[/code]

memcached
[code]
wget http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz
tar xzf memcached-1.2.5.tar.gz
cd memcached-1.2.5
./configure
make
sudo make install
[/code]

pcre
[code]
wget http://nchc.dl.sourceforge.net/sourceforge/pcre/pcre-7.6.tar.bz2
tar xjf pcre-7.6.tar.bz2
cd pcre-7.6
./configure –enable-utf8
make
sudo make install
[/code]

pkg-config
[code]
wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz
tar xzf pkg-config-0.23.tar.gz
cd pkg-config-0.23
make
sudo make install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
[/code]

libxml2
[code]
wget ftp://xmlsoft.org/libxml2/libxml2-2.6.31.tar.gz
tar xzf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
[/code]

lighttpd
[code]
wget http://www.lighttpd.net/download/lighttpd-1.4.19.tar.bz2
tar xjf lighttpd-1.4.19.tar.bz2
cd lighttpd-1.4.19
./configure –with-openssl –with-zlib –without-bzip2 –with-pcre –with-gdbm –with-memcache –with-ldap
make
sudo make install
[/code]

好像大功告成了,还缺啥嘛?

新装 Leopard 安装开发环境全记录》上有4条评论

  1. 你好,感谢你分享的环境配置,我遇到一个问题向请教一下!

    为什么我无法编辑/etc/profile 你是怎么操作的 谢谢

  2. 請問版大
    我的作業環境是
    Mac OS X 10.4.11 Intel Core Duo
    eclipse
    安裝soylatte16-i386-1.0.3後執行視窗化的程式
    出現:
    Exception in thread “main” java.lang.InternalError: Can’t connect to X11 window server using ‘:0.0’ as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)
    at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:131)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    ……
    請問 要如何才能連接X11 使得視窗可以顯示出來?

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据