1. scons是神馬?
scons是linux下的自動構建工具,類似cmake。
2. 安裝
wget http://prdownloads.sourceforge.net/scons/scons-2.2.0.tar.gz .
tar zxvf scons-2.2.0.tar.gz
cd scons-2.2.0
python setup.py install
正常情況下,scons將安裝到${PYTHON_INSTALL_DIR}/bin/下
3. hello world程序
三個文件hello.h hello.c main.c hello.h定義函數void hello(); hello.c中實現該函數,main.c中調用該函數。
編寫SConstruct,scons構建時使用。內容如下:
Program('hello', ['hello.c', 'main.c'])
開始構建
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o hello.o -c hello.c
gcc -o main.o -c main.c
gcc -o hello hello.o main.o
scons: done building targets.
此時二進制文件已經構建完成,scons賊好用。
4. 參考資料
更多配置:http://blog.csdn.net/andyelvis/article/details/7055377
相關代碼下載:http://pan.baidu.com/share/link?shareid=239572&uk=908463093