告别MAMP

大学时代,玩过一阵子Apache+PHP+MySQL,一般是在Linux上,也用过一次FreeBSD。

后来自己的服务器也就一直放在Mac上,之前偷懒,就在网上下载了MAMP凑合着用了。

这次升级到Lion,很不幸,MAMP中的Apache不能起来了,我也没有查看日志。网上搜索了一下,Lion中已经自带Apache2和PHP 5.3了,”System Preferences”->”Sharing”->”Web Sharing”就是Apache2的启动选项,配置文件在/etc/apache2/httpd.conf,把下面这行取消注释就可以启用PHP了:

LoadModule php5_module libexec/apache2/libphp5.so

Lion里已经不自带MySQL了,估计是因为Oracle的原因,所以我根据这篇文章安装了MySQL和phpMyAdmin。并且还安装了MySQLStartItem.pkg,这样在”System Preferences”->”MySQL”中就可以控制MySQL了。

之后我就把原来的MySQL数据库覆盖了过来,位置在/usr/local/mysql/data。

之后把WordPress目录复制到相应位置,修改/etc/apache2/extra/httpd-vhosts.conf,为了让WordPress能正常工作,注意添加Directory以及如下一行:

AllowOverride FileInfo Options

对于PHP,还有一项:

sudo cp /etc/php.ini.default /etc/php.ini
sudo vi /etc/php.ini

修改其中一行:

mysql.default_socket = /tmp/mysql.sock

然后就基本都搞定了。

目前还差的就是升级WordPress和WordPress MU 2.x到最新的3.2.1了。

Clang Static Analyzer with Qt

1. OS: Snow Leopard 64bit

2. Qt: 4.8

cd ~/qt
git clone git://gitorious.org/qt/qt.git work
cd work
git checkout -b origin/4.8 4.8
cp -rf mkspecs/unsupported/macx-clang mkspecs/unsupported/macx-checker

Note: a patch for mkspecs/unsupported/macx-checker/qmake.conf: http://pastebin.com/u7mnkhue

3. Clang Static Analyzer: checker-256

cd ~/dev/packages
wget http://clang-analyzer.llvm.org/checker/checker-256.tar.bz2
tar zxvf checker-256.tar.bz2
cd checker-256
rm bin/clang
rm bin/clang++
cd /usr/local/bin
ln -s /Users/liangqi/dev/packages/checker-256/bin/clang-3.0 clang
ln -s /Users/liangqi/dev/packages/checker-256/bin/clang-3.0 clang++

4. Build

cd ~/build
mkdir qt-48-clang
cd qt-48-clang
export PATH=/usr/local/bin:/Users/liangqi/dev/packages/checker-256:$PATH
/Users/liangqi/qt/work/configure -platform unsupported/macx-checker -nokia-developer -no-webkit -no-qt3support -no-declarative -no-xmlpatterns -no-script -no-scripttools -no-phonon -no-multimedia -nomake tools -nomake demos -nomake examples -fast -verbose -no-framework
scan-build make

5. Output

In the end of the output, you will find a command like “scan-build: Run ‘scan-view /var/folders/QB/QBTpJfK+HfqtpmxTOms2nU+++TI/-Tmp-/scan-build-2011-07-20-3′ to examine bug reports.”, do it!

NOTE: the above way doesn’t work with checker-257!

How to run autotests in Qt for Symbian on Linux and Mac?

Here is the official article for it, Installing Qt for the Symbian platform using Linux (experimental).

The basic idea is same on Linux and Mac OS X.

1. For phone, you need to install Application TRK

S60 5.0/Symbian^1 – s60_5_0_app_trk_3_2_7.sisx
Symbian^3 – s60_tb_9_2_app_trk_3_2_8.sisx

2. Use usb cable to connect your phone and computer, Linux or Mac OS X. Remember to set to “PC Suite” mode or “Nokia Ovi Suite” mode on your phone. Then launch your Application TRK via “RnD Tools”->”TRK”.

3. About the device name for your phone on computer

For Linux, see more details in Configuring the USB Serial Driver on the Linux System. After that, you will find /dev/ttyUSBx and maybe another /dev/ttyUSBy, better to “sudo chmod 777 /dev/ttyUSB*” for them(some Linux distribution do not give the access to normal users for it, like Ubuntu).

For Mac, you could find sth like /dev/cu.usbmodemfaXx and /dev/cu.usbmodemfaXy.

4. To build runonphone, you need to have libusb installed.

For Linux, just follow that documentation, “sudo apt-get install libusb-dev” should be ok for Debian/Ubuntu.

For Mac, “sudo brew install libusb-compat” works for me.

5. Build runonphone, use the qmake in your desktop Qt.

cd ~/qt/qt/tools/runonphone
/usr/bin/qmake
make

6. Build and run your autotests, please check previous blog for the EPOCROOT and PATH environments settings.

cd qt/qt/tests/auto/qdatetime
~/build/s3_gcce/bin/qmake -spec ~/qt/qt/mkspecs/symbian-gcce -o Makefile ~/qt/qt/tests/auto/qdatetime/qdatetime.pro
make sis
~/qt/qt/tools/runonphone/runonphone -p /dev/cu.usbmodemfa44 –sis ~/qt/qt/tests/auto/qdatetime/qdatetime.sis qdatetime.exe

NOTE: Here the /dev/cu.usbmodemfa44 is the device on Mac for me. And for Linux, the device is sth like /dev/ttyUSB1.

Enjoy it!

Build Qt 4.7 with Symbian^3 on Linux and Mac OS X

Similar steps as previous blog.

Here I will only mention the difference between them:

1. Qt 4.7, please wait a while for the merging of 7c499bcfbf7f9c52b3d6523fea8396bd4ab7252e.

git checkout -b 4.7 origin/4.7

2. You could enable the webkit which is inside of 4.7, then the configure line should be like:

~/qt/qt/configure -developer-build -opensource -confirm-license -xplatform symbian-gcce -webkit -fast -silent -nomake examples -nomake demos -nomake tools -nomake tests -qtlibinfix _liang

And for QtWebKit package:

cd ~/build/s3_gcce/src/3rdparty/webkit/WebCore
make sis
copy ~/build/s3_gcce/lib/QtWebKit_liang.sis toyourphone

For the demo browser application:

cd ~/qt/work/demos/embedded/anomaly
make sis
copy anomaly.sis toyourphone

3. Install the above Qt_liang.sis, QtWebKit_liang.sis, analogclock.sis and anomaly.sis, and enjoy them.

Launch it at “QtExamples”->”analogclock”.
Launch it at “QtDemos”->”anomaly”.

Build Qt 4.8 with Symbian^3 on Linux and Mac OS X

Build Qt 4.8 with Symbian^3 on Linux and Mac OS X

Kudos to Kristian Amlie and Thomas Zander for the “make file build system”.

1. OS:

Linux – mine is 2.6.38-8-generic x86_64
Mac OS X – mine is 10.6.8 64bit

2. Symbian^3

NOTE: Looks like Qt is still not the 1st-priority citizen in the Symbian^3 SDKs world, the reason why I say like that is this task, it means that you cannot use any version of Symbian^3 (public) SDKs to build Qt libraries from source. Details in the comment. Then we use the Symbian^3 PDK 3.0.4 for now. I am not sure how long this mirror service will be available there, you’d better backup those files by yourself.

Symbian^3 PDK 3.0.4

Please download binaries_armv5_lib.7z.zip, binaries_armv5_udeb.7z.zip, binaries_armv5_urel.7z.zip, binaries_epoc.7z.zip, binaries_epoc_sdk.7z.zip, binaries_prebuilt.7z.zip, tools_epoc.7z.zip at least.

cd ~
mkdir -p symbian-sdks/pdk304
cd symbian-sdks/pdk304
7z x abovefiles
export EPOCROOT=~/symbian-sdks/pdk304/ //set env for EPOCROOT

The patch for Symbian^3 PDK 3.0.4 is here.

3. Wine

NOTE: The reason for installing wine is we are using the Symbian tools build on Windows, such as rcomp, makesis and many others.

Linux(Debian/Ubuntu): sudo apt-get install wine1.2
Mac OS X: Install wine 1.1.44, and upgrade it to 1.2

Add wine into path
export PATH=/Applications/Wine.app/Contents/Resources/bin:$PATH //for Mac OS X

4. Compilers:

Linux: RVCT 2.2(need commercial license) or GCCE 4.4.1(Symbian ADT Sourcery G++ Lite 4.4-172 for ARM SymbianOS)
Mac OS X: GCCE 4.4.1(Symbian ADT Sourcery G++ Lite 4.4-172 for ARM SymbianOS), after installed to default path, mv /Applications/CodeSourcery/Sourcery G++ Lite/ /Applications/CodeSourcery/Sourcery_G++_Lite. NOTE: need to remove those spaces in the path of compiler

Add compiler path into PATH:
export PATH=/Applications/CodeSourcery/Sourcery_G++_Lite/bin:$PATH

5. Qt 4.8

NOTE: better to use ea7ed6b27301a4834b1bfe0ad4e6e58462647d3e and later.

cd ~
mkdir qt
git clone -n git://gitorious.org/qt/qt.git qt
cd qt
git checkout -b 4.8 origin/4.8

6. Build it

cd ~
mkdir build
cd build
mkdir s3_gcce // this is for the GCCE case, or s3_armcc for RVCT 2.2 case
cd s3_gcce
~/qt/qt/configure -developer-build -opensource -confirm-license -xplatform symbian-gcce -no-webkit -fast -silent -nomake examples -nomake demos -nomake tools -nomake tests -qtlibinfix _liang // this is for GCCE case, or “-xplatform symbian-armcc” for RVCT 2.2 case
make -j8 // maybe fail at somewhere, then just try “cd src;make -j1″ finish it
cd src/s60installs
make sis
cd ~/build/s3_gcce/lib
cp Qt_liang.sis toyourphone
cd ~/qt/qt/examples/widgets/analogclock
~/build/s3_gcce/bin/qmake
make sis
copy analogclock.sis toyourphone

7. Install your own build Qt libraries and application

Goto “Office”->”File Manager”, manually install Qt_liang.sis and analogclock.sis

8. Run your appliation

Launch it at “QtExamples”->”analogclock”. Enjoy it!

Known issues or other topics:
1. There is still some issue to build qtwebkit which the one inside of qt 4.8 or from qtwebkit git repo directly. If I got solution, I will let you know.
2. Mabye write something about runonphone on Linux and Mac OS X, it is a very good tool to test qt applications.

直面死亡?

从7月初开始上挪威语课,到上周末正好3周一期,我们是周一到周四上午有课,所以上周五在公司上班。爆炸时没有听到什么动静,大约1小时后,老婆打来电话,说她那里听到爆炸了。然后上网才看到新闻,开始只有挪威新闻报导,然后是BBC。难道这就是类似911那样的“恐怖主义分子”?然后就打电话告诉在挪威家中的父母,我们一切都好,也许会稍晚一些回家,不清楚市中心会是什么情况。

等老婆要坐车的时候,上网看了一下,通过市中心的公交等都绕道了,接了老婆回到家,吃完饭,也有7点多了,在上网,就看到了Utøya的事情。够狠呀,什么样的环境能早就这样的杀人狂魔呢?而且面对的是“手无寸铁”的14-18岁的少年?

到此,正如网上很多朋友所提到的那样,大家都会断定是和工党有仇的了。

周末就待在家里和妞妞一起玩,偶尔看看新闻,主要还是BBC和CNN,挪威语的新闻还听不懂。

今早又进城上课,学校和大教堂以及政府都不远,课间拍了一些照片。临近中午时,老师通知我们说中午12点要默哀一分钟,有想出去的,最好提前5分钟。大家在教师里默哀了大约4,5分钟,老师说放学了。出学校出来后,就看到大教堂附近的人群好像多了很多。时间匆忙,也只是看了一下人群和纪念的鲜花和蜡烛。

近百条人命就在不远的地方这样离去了,除了人生短暂,也就是这样的无常了。

正因为这件事,也才开始阅读本地挪威语的新闻媒体,目前还是通过Google Chrome翻译后阅读的,希望能早点试着读挪威语原文。

(备注:本文又标题党了。)

最后,是今天的一些照片 – 爆炸枪击之后的奥斯陆

好久没有更新了

看了一下,这竟然是本年度第四篇。

一晃儿,2011的上半年就过去了,时间太快了,在有了妞妞之后就更快了。

小小总结一下上半年:

老婆找到工作了,比我还忙。
妞妞可以走路了,最近一两个月说话很多,不知道等8月份开始进入幼儿园后,双语环境下会是什么状态。
爸妈也过来了,最初一两周还在倒时差,现在基本适应了。
我这里,去年5月底就买了一辆旧车,7月底开始学车,断断续续,终于在昨天第二次考试通过了,拿到挪威驾照。

下半年争取把挪威语学时搞定。

Qt中的一些全局测试用例

近期工作中接触过的,觉得很有意义。

目前这些测试用例都还在在$QTDIR/tests/auto下:

bic
说明:利用g++的-fdump-class-hierarchy参数生成的类信息数据和VTable数据检查二进制兼容性。对于库来说很重要。gen.sh对已发布的版本生成历史数据,然后调用g++ -fdump-class-hierarchy生成当前版本数据再进行比较。只要是支持g++的平台都可以检测。

compilerwarnings
说明:tst_CompilerWarnings::warnings()中对几种编译器的警告进行了检测。

headers
说明:tst_Headers::licenseCheck()中对所有源文件进行协议检查。tst_Headers::privateSlots()中对所有头文件检查了私有槽必须含有“_q_”。tst_Headers::macros()对所有头文件检查了宏。

symbols
说明:利用nm检查库中函数名和全局变量。tst_Symbols::prefix()中利用nm -g -C -D –format=posix –defined-only对库中的函数名称的前缀进行检查。tst_Symbols::globalObjects()中利用nm -C –format=posix对库中的全局静态对象进行检测,应该是不能有的。