Android 第一季

来源:互联网 发布:sql server cast用法 编辑:程序博客网 时间:2024/04/28 06:15

1、Android NDK动态库的调用

NDK动态库的调用分两种情况。

第一种是:so库和调用程序在同一个目录和源程序 通过同一个mk文件来编译;

另外一种情况是so是外部已经编译好了的,调用程序加载调用。下面我们就来分析下面2种so的调用情况:

  第一部分: 内部so调用

  A. 先看下工程的目录:

test01.java :Java文件

  test01.c 主so,生成libtest.so,在libtest.so中调用libtutorial.so中的方法

  tutorial01.ctutorial02.c tutorial02.h :生成libtutorial.so


2、Compile Linux dynamic library

调用动态库的文件如下图:

生成动态库的文件如下图:

 

 

 

 

终端编译过程文件如下:

动态库的主函数的文件如下:

文件名如下:

 

 

 

 

编译动态库的终端命令:

3、Ubuntu启动root权限

注意在图中标示的地方鼠标会停留等待输入

4、按照类似windows平台上面的方法安装Debian上面的Ubuntu上面的平台

 

5、调整Debian系统上Eclipse的多种语言调试的方法

(假设已经下载了Eclipse Linux 32的版本)

注意:下的版本最好不超3.5.1Android不兼容!

第一步:进入 http://www.eclipse.org/cdt/downloads.php 网页。

第二步:将复制的网址进行复制并且加入

http://download.eclipse.org/tools/cdt/releases/galileo

注意:此处最后一个单词可以根据你的版本的不同来设定。

第三步:勾选下面的列表里面的两个选项,next后Eclipse会自动安装。

https://dl-ssl.google.com/android/eclipse/

6、Debian Android 安装过程

7、查看Debian下环境变量的指令

8、Eclipse出错检查java的安装

注意:安装QCreator候它里面会自一些Java,但是我们还需要从新安装JAVA

第一步:通过终端进入Java的下载的路径

第二步:输入./jre-6u22-linux-i586.bin

第三步:安装之后输入如下图所示的指令检查安装的版本,我此时检查结果还是不对。

9、根据AndroidLight 编译Qt

第一步:下载Qt-Embed-Linux-Library并且解压压缩包

第二步:进入如下图所示的目录,修改文件

10、安装Debian上面的Git工具

第一步:从Debian系统下进入Git目录。我的是在/mnt/hpfs/DebianSoft/git-1.6.3.3

第二步:进入git下载后存放的路径,在终端中输入configure进行预编译,具体截图如下图所示.-prefix的意思就是指所安装的目录。

第三步:

第四步:安装

exportPATH=/urs/local/git/bin:/urs/local/git/libexec/git-core:$PATH

第五步:安装问题.

原因分析:可能是因为我创建在外部文件的关系.只要把安装的方案改在系统内就可以了.

11、编译Qt在Android系统上。

第一个问题:git取得远程库的方式和方法。

第一步:首先进行初始化,然后查看一下创建的库的目录,在Linux下查看的是没有内容,但是在虚拟机外部查看里面是有文件的。

第二步:git的使用方法。

Git工具的初始化:

(1)git clone

(2)git init与git remote

第三步:Gitorious创建PublicSSH Key

首先,必须进入网站如下的界面

网址为:https://secure.gitorious.org/~palin1989/keys

命令为:cd ~/.ssh

命令为: ssh-keygen -t rsa -C"zhouzhenyou@gmail.com"

命令为:apt-get install xclip

命令为:cat ~/.ssh/id_rsa.pub

12、改良git下载工具

第一步:

第二步:

命令为:curl http://android.git.kernel.org/repo>~/bin/repo

命令为:

12、安装Gitorious在本地服务器上

第一步:安装git和系统必备的工具

命令:apt-get install -ygit-core git-svn

命令:apt-get update

命令:sudo aptitude install mysql-server mysql-clientlibmysqlclient15-dev

第二步:安装Ruby和必备的库

命令:cd/mnt/hgfs/DebianSoft/ruby-1.9.1-p243

命令:./configure-prefix=/usr/local/ruby

命令:ruby extconf.rb

第三步:安装公共库

命令:apt-get install -ylibonig-dev libyaml-dev geoip-bin libgeoip-dev libgeoip1

第四步:安装RMagick工具

命令:apt-get install -yimagemagick libmagick9-dev

命令:exportPATH+=:/usr/local/ruby/bin

命令:gem install --no-ri--no-rdoc rmagick

第五步:安装sphinx

13、怎样用git工具通过一个HTTP网络连接代理(工具)

第一步:安装socat

14、安装NFS

第一步:aptitudeinstall  nfs-common nfs-kernel-serverportmap

第二步:aptitudeinstall  nfs-common portmap

15.git代理设置和取消代理设置

第一步:下载安装connect-proxy这个工具

第二步:在/bin/gitproxy设置这个脚本

第三步:取消代理设置

 

参考资料:

1、http://appdev.189works.com/?action-viewnews-itemid-3784-page-1

2、http://code.google.com/p/android-lighthouse/

3、http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server

4、http://allenshao.javaeye.com/blog/600383

5、http://tools.rosinstrument.com/cgi-bin/sps.pl?pattern=;(%5c%2b)|(1080;)&max=100&nskip=0&file=proxlog.csv&refresh=61 (代理)

6、http://blog.csdn.net/truewell/archive/2009/08/19/4462225.aspx

 

第三部分问题集锦

 

1、 Eclipse无法启动程序,安装****.apk失败。

2、  AndroidNDK环境

下载Android 1.5 NDK, Release 1 For Windows 并解压到D:\android-ndk-1.5_r1
2.下载Cygwin, 执行setup.exe并开始安装(根据网络速度快慢而定, 预计安装需要20分钟左右)
注意:1. 选择台湾的http站点,速度会快很多; 2.开发选项里必须勾选gcc和make,否则后期无法编译
3.执行桌面图标Cygwin,出现linuxshell提示符后, 修改当前目录(/home/username)下.bash_profile文件, 加入如下内容在文件尾部
ANDROID_NDK_ROOT=/cygdrive/d/android-ndk-1.5_r1
export ANDROID_NDK_ROOT
4.退出Cygwin,重新进入,执行以下命令
cd $ANDROID_NDK_ROOT
build/host-setup.sh
一切顺利的话会提示设置成功,如果出错, 则检查错误并修复
5.编译samplehello-jni
进入Cygwin
cd $ANDROID_NDK_ROOT
make APP=hello-jni


一切顺利则会生成libhello-jni.so文件在

$ANDROID_NDK_ROOT/apps/hello-jni/project/libs/armeabi目录下
6.启动预先配置好的Eclipse + ADT环境,创建一个AndroidProject,选择Create project form existring source
Location = D:\android-ndk-1.5_r1\apps\hello-jni\project, 直接确认即可开始编译并生成apk文件
7.运行这个Project,及可看到效果.
8.祝大家好运
二、搭建Android NDK环境

NDK 编译需要用到Cygwin中的make 和gcc, 所以先来下载并安装Cygwin。先进入www.cygwin.com,点击其中的Installor update now 链接。

这将下载一个名为setup.exe 的安装文件,下载后双击启动安装。

Cygwin 的安装有两种方式,一种是本地安装,这里采用另一种在线安装方式。

1 .启动安装

2 .下一步

3 .选择在线安装方式

4. 选择安装路径

5. 选择下载文件存放的目录

6. 选择网络连接方式

7. 选择下载镜像站点

8 .开始下载安装

9 .选择安装项

10 .启动Cygwin, 测试安装

输入命令检查

出现以上版本信息则表明make 和gcc 已经安装成功。

11. 赶紧用NDK来编译简单例子

A ). 设置环境变量

先找到安装路径下的.bash_profile 文件,我的环境位于:C:\cygwin\home\Administrator。用UltraEdit 打开,添加以下两句:

ANDROID_NDK_ROOT=/cygdrive/e/develop/android/android-NDK/android-ndk-1.5_r1

export ANDROID_NDK_ROOT

其中前一句需要修改为你自己的路径,保存后,重新启动Cygwin 。

注意:这里如果是中文OS 使用记事本或者写字板打开编辑后,重新启动Cygwin 会报错。

B ). 配置Android NDK环境

C). 编译例子

先拷贝build/out 下的host 目录以及其下的config.mk 文件到NDK 根目录的out目录下。

编辑完成可以看到NDK 根目录下的out目录多出了apps子目录,其他有编译好的共享文件库。

3、  文字流的处理

Java代码

1        package com.Aina.Android; 

2          

3        import java.util.Vector; 

4          

5        import android.graphics.Canvas; 

6        import android.graphics.Color; 

7        import android.graphics.Paint; 

8        importandroid.graphics.Paint.FontMetrics; 

9        import android.view.KeyEvent; 

10      

11    public class TextUtil { 

12      

13        private int mTextPosx = 0;// x坐标 

14        private int mTextPosy = 0;// y坐标 

15        private int mTextWidth = 0;// 绘制宽度 

16        private int mTextHeight = 0;// 绘制高度 

17        private int mFontHeight = 0;// 绘制字体高度 

18        private int mPageLineNum = 0;// 每一页显示的行数 

19        private int mCanvasBGColor = 0;// 背景颜色 

20        private int mFontColor = 0;// 字体颜色 

21        private int mAlpha = 0;// Alpha值 

22        private int mRealLine = 0;// 字符串真实的行数 

23        private int mCurrentLine = 0;// 当前行 

24        private int mTextSize = 0;// 字体大小 

25        private String mStrText =""; 

26        private Vector mString = null; 

27        private Paint mPaint = null; 

28      

29        public TextUtil(String StrText, int x, inty, int w, int h, int bgcolor, 

30                int textcolor, int alpha, inttextsize) { 

31            mPaint = new Paint(); 

32            mString = new Vector(); 

33            this.mStrText = StrText; 

34            this.mTextPosx = x; 

35            this.mTextPosy = y; 

36            this.mTextWidth = w; 

37            this.mTextHeight = h; 

38            this.mCanvasBGColor = bgcolor; 

39            this.mFontColor = textcolor; 

40            this.mAlpha = alpha; 

41            this.mTextSize = textsize; 

42        } 

43      

44        public void InitText() { 

45            mString.clear();// 清空Vector 

46            // 对画笔属性的设置 

47    //      mPaint.setARGB(this.mAlpha,Color.red(this.mFontColor), Color 

48    //              .green(this.mFontColor),Color.blue(this.mFontColor)); 

49            mPaint.setTextSize(this.mTextSize); 

50            mPaint.setColor(Color.BLUE); 

51            this.GetTextIfon(); 

52        } 

53      

54        /**

55         * 得到字符串信息包括行数,页数等信息

56         */ 

57        public void GetTextIfon() { 

58            char ch; 

59            int w = 0; 

60            int istart = 0; 

61            FontMetrics fm =mPaint.getFontMetrics();// 得到系统默认字体属性 

62            mFontHeight = (int)(Math.ceil(fm.descent - fm.top) + 2);// 获得字体高度 

63            mPageLineNum = mTextHeight / mFontHeight;//获得行数 

64            int count =this.mStrText.length(); 

65            for (int i = 0; i < count; i++){ 

66                ch = this.mStrText.charAt(i); 

67                float[] widths = new float[1]; 

68                String str =String.valueOf(ch); 

69                mPaint.getTextWidths(str,widths); 

70                if (ch == '\n') { 

71                    mRealLine++;// 真实的行数加一 

72                    mString.addElement(this.mStrText.substring(istart,i)); 

73                    istart = i + 1; 

74                    w = 0; 

75                } else { 

76                    w += (int)Math.ceil(widths[0]); 

77                    if (w > this.mTextWidth){ 

78                        mRealLine++;// 真实的行数加一 

79                        mString.addElement(this.mStrText.substring(istart,i)); 

80                        istart = i; 

81                        i--; 

82                        w = 0; 

83                    } else { 

84                        if (i == count - 1) { 

85                            mRealLine++;// 真实的行数加一 

86                            mString.addElement(this.mStrText.substring(istart, 

87                                    count)); 

88                        } 

89                    } 

90                } 

91            } 

92        } 

93      

94        /**

95         * 绘制字符串

96         * 

97         * @param canvas

98         */ 

99        public void DrawText(Canvas canvas) { 

100         for (int i = this.mCurrentLine, j = 0;i < this.mRealLine; i++, j++) { 

101             if (j > this.mPageLineNum){ 

102                 break; 

103             } 

104             canvas.drawText((String)(mString.elementAt(i)), this.mTextPosx, 

105                     this.mTextPosy +this.mFontHeight * j, mPaint); 

106         } 

107     } 

108     /**

109      * 翻页等按键处理

110      * @param keyCode

111      * @param event

112      * @return

113      */ 

114     public boolean KeyDown(int keyCode,KeyEvent event) 

115     { 

116         if (keyCode ==KeyEvent.KEYCODE_DPAD_UP) 

117         { 

118             if (this.mCurrentLine > 0) 

119             { 

120                 this.mCurrentLine--; 

121             } 

122         } 

123         else if (keyCode ==KeyEvent.KEYCODE_DPAD_DOWN) 

124         { 

125             if ((this.mCurrentLine +this.mPageLineNum) < (this.mRealLine - 1)) 

126             { 

127                 this.mCurrentLine++; 

128             } 

129         } 

130         return false; 

131     } 

132 } 



Java代码

133 package com.Aina.Android; 

134   

135 import android.content.Context; 

136 import android.graphics.Canvas; 

137 import android.graphics.Color; 

138 import android.graphics.Paint; 

139 import android.view.KeyEvent; 

140 import android.view.View; 

141   

142 public class MyView extends Viewimplements Runnable{ 

143   

144     private Paint mPaint; 

145     private int mICount = 0; 

146     private TextUtil mTextUtil; 

147   

148     public MyView(Context context) { 

149         super(context); 

150         mPaint = new Paint(); 

151         String string = "测试自动换行(第1行)\n\n测试自动换行(第2行)\n测试自动换行(第3行)\n测试自动换行(第4行)\n测试自动换行(第5行)\n测试自动换行(第6行)\n测试自动换行(第7行)"; 

152         mTextUtil = new TextUtil(string, 15,150, 300, 80, 0x000000, 0xff00ff, 

153                 255, 16); 

154         mTextUtil.InitText(); 

155         new Thread(this).start(); 

156     } 

157   

158     @Override 

159     protected void onDraw(Canvas canvas) { 

160         super.onDraw(canvas); 

161         canvas.drawColor(Color.BLACK); 

162         mPaint.setAntiAlias(true); 

163         if (mICount < 100) { 

164             mICount++; 

165         } 

166         mPaint.setColor(Color.RED); 

167         canvas.drawText("装在进度:" + mICount + "%......", 10, 20, mPaint); 

168         mTextUtil.DrawText(canvas); 

169     } 

170   

171     @Override 

172     public void run() { 

173         Thread.currentThread(); 

174         while(!Thread.interrupted()){ 

175             try{ 

176                 Thread.sleep(10); 

177             }catch(Exception ex){ 

178                 ex.printStackTrace(); 

179                 Thread.currentThread().interrupt(); 

180             } 

181             this.postInvalidate(); 

182         } 

183     } 

184     public boolean onKeyDown(int keyCode,KeyEvent event) { 

185           

186         return mTextUtil.KeyDown(keyCode,event); 

187     } 

188 } 



Java代码

189 package com.Aina.Android; 

190   

191 import android.app.Activity; 

192 import android.os.Bundle; 

193 import android.view.KeyEvent; 

194   

195 public class Test_DrawText extendsActivity { 

196     /** Called when the activity is firstcreated. */ 

197     private MyView mv ; 

198     @Override 

199     public void onCreate(BundlesavedInstanceState) { 

200         super.onCreate(savedInstanceState); 

201         mv = new MyView(this); 

202         setContentView(mv); 

203     } 

204   

205     @Override 

206     public boolean onKeyDown(int keyCode, KeyEventevent) { 

207         mv.onKeyDown(keyCode, event); 

208         return super.onKeyDown(keyCode,event); 

209     } 

210       

211 } 

4、AndroidQt

第一步:wget http://android-lighthouse.googlecode.com/files/qadk-r4-1.tar.bz2

(说明:终端中输入上面的指令或者直接去网站下载)

第二步:git clonegit://gitorious.org/~taipan/qt/android-lighthouse.git

(说明:本地电脑需安装git工具,才能够执行这些指令)

或者可以直接从网络上下载,方法如图所示

(说明:此步骤的目的就是下载文件,但是此文件比较难下载,所以两种方法都可以试一试

笔者在WINDOW XP & WIN7上面网页下载全部失败,在Debian上面网页下载也失败,

git clone获取比较大的源码时,不能断点续传, 在传输本源码的时候容易间断,用git fetch 在.git的文件目录下面进行继续传输。如下图所示)

下图是下载完成后的终端

第三步:在mkspecs/android-g++/qmake.conf这个文件里修改 NDK_ROOT 变量为你电脑上面qadk目录所在的位置, 同时,检查ANDROID_PLATFORM 这个变量的值是否符合你电脑上的平台。

第四步:用androidconfig.sh脚本来预编译Qt

第五步:编译QT

中间错误:

第一个错误:

第一个解决方法:

root:~# cd /mnt/hgfs/DebianSoft

root:/mnt/hgfs/DebianSoft# dpkg-i libcloog-ppl0_0.15.9-1_i386.deb

(正在读取数据库 ... 系统当前总共安装有 116857 个文件和目录。)

正预备替换 libcloog-ppl0 0.15.9-1 (使用 libcloog-ppl0_0.15.9-1_i386.deb)...

正在解压缩将用于更替的包文件 libcloog-ppl0 ...

dpkg:依赖关系问题使得 libcloog-ppl0 的配置工作不能继续:

 libcloog-ppl0 依赖于 libgmpxx4ldbl;然而:

 未曾安装软件包“libgmpxx4ldbl”。

 libcloog-ppl0 依赖于 libppl-c2;然而:

 未曾安装软件包“libppl-c2”。

 libcloog-ppl0 依赖于 libppl7;然而:

 未曾安装软件包“libppl7”。

dpkg:处理 libcloog-ppl0 (--install)时出错:

 依赖关系问题 - 仍未被配置

在处理时有错误发生:

 libcloog-ppl0

root:/mnt/hgfs/DebianSoft# dpkg-i libgmpxx4ldbl_4.3.2+dfsg-1_i386.deb

选中了曾被取消选择的软件包 libgmpxx4ldbl。

(正在读取数据库 ... 系统当前总共安装有 116857 个文件和目录。)

正在解压缩 libgmpxx4ldbl (从 libgmpxx4ldbl_4.3.2+dfsg-1_i386.deb) ...

dpkg:依赖关系问题使得 libgmpxx4ldbl 的配置工作不能继续:

 libgmpxx4ldbl 依赖于 libstdc++6 (>=4.4.0);然而:

系统中 libstdc++6 的版本为 4.3.2-1.1。

dpkg:处理 libgmpxx4ldbl (--install)时出错:

 依赖关系问题 - 仍未被配置

在处理时有错误发生:

 libgmpxx4ldbl

root:/mnt/hgfs/DebianSoft#apt-get install libstdc++6-4.4-dev

正在读取软件包列表... 完成

正在分析软件包的依赖关系树      

正在读取状态信息... 完成 

E: 无法找到软件包 libstdc++6-4.4-dev

root:/mnt/hgfs/DebianSoft# dpkg-i libstdc++6_4.4.5-8_i386.deb

(正在读取数据库 ... 系统当前总共安装有 116863 个文件和目录。)

正预备替换 libstdc++6 4.3.2-1.1 (使用 libstdc++6_4.4.5-8_i386.deb) ...

正在解压缩将用于更替的包文件 libstdc++6 ...

dpkg:依赖关系问题使得 libstdc++6 的配置工作不能继续:

 libstdc++6 依赖于 gcc-4.4-base (=4.4.5-8);然而:

 未曾安装软件包“gcc-4.4-base”。

dpkg:处理 libstdc++6 (--install)时出错:

 依赖关系问题 - 仍未被配置

在处理时有错误发生:

 libstdc++6

root:/mnt/hgfs/DebianSoft#apt-get update gcc

E:  update 命令是不需任何参数的

root:/mnt/hgfs/DebianSoft#apt-get install gcc

正在读取软件包列表... 完成

正在分析软件包的依赖关系树      

正在读取状态信息... 完成 

gcc 已经是最新的版本了。

您可能需要运行“apt-get -finstall”来纠正下列错误:

下列的软件包有不能满足的依赖关系:

 libcloog-ppl0: 依赖: libppl-c2 但却无法安装它

                 依赖: libppl7 但却无法安装它

 libstdc++6: 依赖: gcc-4.4-base (= 4.4.5-8) 但却无法安装它

E: 有未能满足的依赖关系。请尝试不指明软件包的名字来运行“apt-get -f install”(也可以指定一个解决办法)。

root:/mnt/hgfs/DebianSoft# dpkg-i gcc-4.4-base_4.4.5-8_i386.deb

选中了曾被取消选择的软件包 gcc-4.4-base。

(正在读取数据库 ... 系统当前总共安装有 116863 个文件和目录。)

正在解压缩 gcc-4.4-base (从 gcc-4.4-base_4.4.5-8_i386.deb) ...

正在设置 gcc-4.4-base (4.4.5-8) ...

root:/mnt/hgfs/DebianSoft# dpkg-i libstdc++6_4.4.5-8_i386.deb

(正在读取数据库 ... 系统当前总共安装有 116871 个文件和目录。)

正预备替换 libstdc++6 4.4.5-8 (使用 libstdc++6_4.4.5-8_i386.deb) ...

正在解压缩将用于更替的包文件 libstdc++6 ...

正在设置 libstdc++6 (4.4.5-8) ...

ldconfig: 文件 /lib/libmp.so.3 为空,未检查。

ldconfig: /lib/libmp.so.3 不是符号连接

 

root:/mnt/hgfs/DebianSoft# dpkg-i libgmpxx4ldbl_4.3.2+dfsg-1_i386.deb

(正在读取数据库 ... 系统当前总共安装有 116871 个文件和目录。)

正预备替换 libgmpxx4ldbl 2:4.3.2+dfsg-1 (使用libgmpxx4ldbl_4.3.2+dfsg-1_i386.deb) ...

正在解压缩将用于更替的包文件 libgmpxx4ldbl ...

正在设置 libgmpxx4ldbl (2:4.3.2+dfsg-1) ...

ldconfig: 文件 /lib/libmp.so.3 为空,未检查。

ldconfig: /lib/libmp.so.3 不是符号连接

 

root:/mnt/hgfs/DebianSoft# dpkg-i libcloog-ppl0_0.15.9-1_i386.deb

(正在读取数据库 ... 系统当前总共安装有 116871 个文件和目录。)

正预备替换 libcloog-ppl0 0.15.9-1 (使用 libcloog-ppl0_0.15.9-1_i386.deb)...

正在解压缩将用于更替的包文件 libcloog-ppl0 ...

dpkg:依赖关系问题使得 libcloog-ppl0 的配置工作不能继续:

 libcloog-ppl0 依赖于 libppl-c2;然而:

 未曾安装软件包“libppl-c2”。

 libcloog-ppl0 依赖于 libppl7;然而:

 未曾安装软件包“libppl7”。

dpkg:处理 libcloog-ppl0 (--install)时出错:

 依赖关系问题 - 仍未被配置

在处理时有错误发生:

 libcloog-ppl0

root:/mnt/hgfs/DebianSoft# dpkg-i libppl-c2_0.10.2-6_i386.deb

选中了曾被取消选择的软件包 libppl-c2。

(正在读取数据库 ... 系统当前总共安装有 116871 个文件和目录。)

正在解压缩 libppl-c2 (从 libppl-c2_0.10.2-6_i386.deb) ...

dpkg:依赖关系问题使得 libppl-c2 的配置工作不能继续:

 libppl-c2 依赖于 libppl7 (= 0.10.2-6);然而:

 未曾安装软件包“libppl7”。

dpkg:处理 libppl-c2 (--install)时出错:

 依赖关系问题 - 仍未被配置

在处理时有错误发生:

 libppl-c2

root:/mnt/hgfs/DebianSoft# dpkg-i libppl7_0.10.2-6_i386.deb

选中了曾被取消选择的软件包 libppl7。

(正在读取数据库 ... 系统当前总共安装有 116874 个文件和目录。)

正在解压缩 libppl7 (从 libppl7_0.10.2-6_i386.deb) ...

正在设置 libppl7 (0.10.2-6) ...

ldconfig: 文件 /lib/libmp.so.3 为空,未检查。

ldconfig: /lib/libmp.so.3 不是符号连接

 

root:/mnt/hgfs/DebianSoft# dpkg-i libppl-c2_0.10.2-6_i386.deb

(正在读取数据库 ... 系统当前总共安装有 116884 个文件和目录。)

正预备替换 libppl-c2 0.10.2-6 (使用 libppl-c2_0.10.2-6_i386.deb) ...

正在解压缩将用于更替的包文件 libppl-c2 ...

正在设置 libppl-c2 (0.10.2-6) ...

ldconfig: 文件 /lib/libmp.so.3 为空,未检查。

ldconfig: /lib/libmp.so.3 不是符号连接

 

root:/mnt/hgfs/DebianSoft# dpkg-i libcloog-ppl0_0.15.9-1_i386.deb

(正在读取数据库 ... 系统当前总共安装有 116884 个文件和目录。)

正预备替换 libcloog-ppl0 0.15.9-1 (使用 libcloog-ppl0_0.15.9-1_i386.deb)...

正在解压缩将用于更替的包文件 libcloog-ppl0 ...

正在设置 libcloog-ppl0 (0.15.9-1) ...

ldconfig: 文件 /lib/libmp.so.3 为空,未检查。

ldconfig: /lib/libmp.so.3 不是符号连接

 

root:/mnt/hgfs/DebianSoft# dpkg-i libgmp3c2_4.3.2+dfsg-1_i386.deb

(正在读取数据库 ... 系统当前总共安装有 116884 个文件和目录。)

正预备替换 libgmp3c2 2:4.2.2+dfsg-3 (使用 libgmp3c2_4.3.2+dfsg-1_i386.deb)...

正在解压缩将用于更替的包文件 libgmp3c2 ...

正在设置 libgmp3c2 (2:4.3.2+dfsg-1) ...

ldconfig: 文件 /lib/libmp.so.3 为空,未检查。

ldconfig: /lib/libmp.so.3 不是符号连接

第二个错误:文件as的格式出错

第二个错误解决方案:替换as文件(与老版本替换)

第三个问题:大量的.o文件缺失

第三个错误解决方案:(取消编译其中一个)

第六步:设定Qt库

(说明:如果Qt编译成为共享库,应该拷贝qt库到)

 

15、Debian新增硬盘和增加虚拟机硬盘空间

15、Debian下安装arm交叉编译环境

第一步:安装工具链并且验证工具链。

第二步:设置qt里面的

5、Ubuntu获得root权限

上述的解决方法中,我的虚拟机的情况如下,没有Login window

六、eclipse调试的方法(已整理)

安装JAVA的方法(Ubuntu):

第一步:终端中输入指令调整用户权限并进行创建文件夹和安装文件

[root@localhost~]#su

[root@localhost~]#mkdir /usr/java

[root@localhost~]#cd usr/java

[root@localhost~]#cp /mnt/hgfs/UbuntuSoft/ jre-6u22-linux-i586.bin  /usr/java

(此步是复制下的java文件到/usr/java下面.此步可用可不用)

[root@localhost~]#chmod +x jre-1_5_0_09-linux-i586.bin

[root@localhost~]#./jre-6u22-linux-i586.bin

注意:此步会将JAVA安装在usr/java/jre1.6.0_22个目下。

[root@localhost~]#vi /etc/profile

注意:在最后一行行添加.

export PATH=/usr/java/jre1.5.0_09/bin:$PATH

export JAVA_HOME=/usr/java/jre1.5.0_09
export CLASSPATH=$JAVA_HOME/lib

[root@localhost~]#reboot

注意:开机后打开端。

[root@localhost~]#export

[root@localhost~]#java -version

七、常用Eclipse

1、Eclipse的Workspace配置

            Eclipse也采用Workspace→Project,种两的工程组织方式。当启Eclipse,它先会Workspace Launcher对话框,指定一个Workspace的位置。你可以在Workspace:后的ComboBox中选择打开的Workspace位置,也可以入一个新的Workspace位置。

Workspace位置实际上是一个普通的目位置,唯一的区别是:在里目中会有一个叫.metadata的子目,Eclipse会将Workspace相关的所有数据、配置等放在个目里面。所以,如果你指定的Workspace位置中没有.metadata目,Eclipse就会在你指定的位置建.metadata,即新建了一个Workspace

Eclipse后,可以在菜File→SwitchWorkspace中切到不同的Workspace中。

之,Workspace是一Project的容器,目的是:了方便管理、组织工程。一个Project认时承它所在的Workspace中的一些置。所以在用Eclipse-CDT建立C/C++工程之前,先置好Workspace的配置是非常必要的。Eclipse中Workspace的配置都在:WindowPreferences置。Preferences对话框中的配置非常多,有候很找到需要的配置里有个技巧:Preferences对话框左配置录树的上面有个编辑框,它支持配置名字索引找,将配置的名字入后,就会在目录树中列出所有包含此名字的配置,例如:想置C/C++法高亮,但又不清它在哪个配置里,可以直接在编辑框中入:color,目录树中就会示所有包括"color"的配置,接下来就很容易找到C/C++法高亮配置了,如下

下面是我通常使用的Workspace置。

Workspace的一般配置

Workspace的一般配置在:Preferences对话框下的General配置项下。General配置项下的设置和Eclipse中特定的编程语言环境无关,它是Eclipse基本环境的配置。我常用的General配置有以下一些:

颜色与字体

在:GeneralAppearanceColors and Fonts 中,可以设置Eclipse各个窗口使用的字体、颜色。我通常设置的是:BasicText Font,它是Eclipse中大多数窗口显示文本的字体,比如:C/C++的源码编辑窗口就是继承这里的字体来显示C/C++源代码,其字体配置位置为:C/C++EditorC/C++ Editor TextFont。在Windows下,我的Text Font默认字体为:CourierNew 10,在显示文本时,中文字符使用系统的默认中文字体:宋体,最后表现出来的字体效果是等宽的,适合用作显示源代码文本。

快捷键

在:GeneralKeys 中,可以查看/设置Eclipse中使用的快捷键。每个快捷键的设置包括:Command,快捷键执行的命令;Binding,快捷键的按键绑定;When,何时允许激活快捷键功能,比如:C/C++ Editor,表示在C/C++编辑器窗口中;Makefile Editor,表示在Makefile编辑器窗口中。在Conflicts列表中显示冲突的快捷键。Keys配置项中包含了三套预置的快捷键设置模式:Default、Microsoft Visual Studio、Emacs。

Eclipse的启动与关闭

在:GeneralStartup and Shutdown 中,可以设置Eclipse启动与关闭时的行为,包括:Eclipse启动时自动激活的插件。如果需要在Eclipse启动时,显示Workspace Launcher对话框来选择工作的Workspace,可以将这里的Prompt for workspace onstartup复选框选上(默认为选上)。

工程自动生成与保存

在:GeneralWorkspace 中,包含与工程自动生成、保存相关的选项。常用的有:

Build automatically:一般将这个选项去掉,因为如果选择上的话,当保存已修改的源代码文件后,或执行Clean工程后,都会自动执行Build工程。这个选项也可以通过Eclipse菜单:ProjectBuild Automatically 设置。

Save automatically beforebuild:一般将这个选项选择,意思是:在执行Build工程之前,先保存工程,包括保存已修改的源代码文件。

Workspace save interval:指定Workspace中所有工程的自动保存时间间隔,以分钟为单位。

文本文件的字符集编码和换行符类型

在:GeneralWorkspace 中,可以设置文本文件的字符集编码和换行符类型。Eclipse默认继承系统的字符集设置和换行符类型,例如:在中文Windows下,Text file encoding的Default值为GBK。如果经常编辑在Windows与Linux下同时工作的源代码,为了方便工程的移植性,可以显式地将Text file encoding设置为UTF-8,并将New text file line delimiter设置为Unix。

注意

当设置Textfile encoding为UTF-8后,Eclipse新建的文本文件为不带BOM的UTF-8编码。

MinGW GCC 4和Linux GCC 4对不带BOM的UTF-8编码的源文件支持都很好,所以设置Text file encoding为UTF-8,是满足方便代码移植的需求的。

无论是使用Console还是GUI的形式,要在屏幕上输出期望的字符串文本,应满足下列三个条件:

在源程序中,使用合适的基本字符类型,如:char、wchar_t。并对程序依赖的运行环境、库,调用它们提供的接口,设置合适的字符集上下文,比如:C标准库的setlocale()函数,C++标准库的locale类。

源程序本身用合适的字符集编码保存。

程序依赖的运行环境、库,它们必需能够支持和适配程序所使用的字符集,例如:当程序通过C标准库,最终向stdout输出UTF-8编码的字符串时,下层用于显示输出的终端设备或控制台环境,必需使用UTF-8编码作为活动字符集。Windows下可以用chcp.com更改当前控制台的活动字符集,Gnome下可以在gnome-terminal的菜单中改变活动字符集。

文本编辑器的设置

文本编辑器的一般配置在:PreferencesGeneralEditorsText Editors

这里的部分配置会影响到C/C++源代码编辑器窗口中的源代码显示。Text Editors中常用的配置项有:

Displayed tab width:Tab的宽度,通常为4个空格。在C/C++源代码编辑器中,这里的配置会被C/C++的Code Style中的配置覆盖,即这里的配置对C/C++源代码编辑器显示源代码文本不起作用。

Insert spaces for tabs:键入Tab时,实际输入的是Tab宽度数目的空格字符。在C/C++源代码编辑器中,这里的配置会被Code Style中的配置覆盖。

Highlight current line:高亮当前编辑的文本行。

Show print margin:显示列边线。显示边线的列数Print margin column通常设置为80个字符。这个功能对程序员来说很贴心:当一行代码超过列边线时,程序员就知道这行写地有些过长了,应该换行排版。列边线通常设置为80个字符,是因为早期的字符终端通常是:25行 × 80字符/行。

Show line numbers:在每行文本前显示行数。显示行数后,行数和每行文本间看起来很拥挤,况且在Eclipse状态栏已经显示当前编辑光标所在的行、列数,所以我通常把这个设置去掉。

Show range indicator:在光标所在的文本区域前显示一个颜色块,表示这个范围内的文本属于同一个文本区域。这又是一个很贴心的功能,对于C/C++编辑器,一个函数过程就被识别为一个文本区域。

Show whitespace characters:以特殊的图形符号显示空白字符。空白字符包括:空格(SP)、Tab、回车(CR)、换行(LF)等。另外,除了在Workspace的Preferences中可以启动这个功能外,还可以在Eclipse的工具条中点击按钮:,来立即启动/停止显示空白字符的功能。

 

Eclipse中引用MinGW工具集

Eclipse-CDT支持多种开发工具集(DevelopmentToolchain):MinGW,Cygwin,Linux等,对于这些工具集,Eclipse-CDT会帮你自动设置常用的编译、链接选项,并且可以在Project的Properties设置中使用图形界面来调整编译、链接选项。如果要使用Eclipse不直接支持的工具集,比如:VC的工具集,则需要自己写Makefile来从Eclipse外部管理编译、链接选项。

Preferences对话框的位置:C/C++New CDT project wizard 中,可以查看已被Eclipse识别的MinGW工具集:MinGW GCC。同时,可以在这里把MinGW GCC设为某一特定Project type(工程类型,包括:Executable、Shared Library、Static Library、Makefile Project)的默认工具集。

Preferences对话框的位置:C/C++New CDT project wizardMakefile Project 中,可以进行MakefileProject工程类型的工具集配置,这些配置也可以在每个工程的属性中设置。

Builder Settings属性页中,可以设置使用外部生成器(External builder)的命令,默认是:make。有时MinGW工具集中将GNU Make命名为mingw32-make,可以在Build command:后输入期望的生成器命令名。

Behaviour属性页中,可以设置生成器的行为参数,比如对于大多make类工具:Build工程时,一般的参数为:all;Clean工程时,一般的参数为clean。另外,最好将Build on resource save(Auto build)复选框去掉,它的意思是:当保存资源时,比如:保存源代码文件时,自动进行Build工程。

 

代码风格、模板与高亮语法

C/C++代码风格

C/C++代码风格的配置位置为:PreferencesC/C++Code Style。C/C++代码风格设置,包括:缩进方式、大括号({})的换行方式、单词间的空白字符设置等。

Code Style已有4个内建的C/C++代码风格配置:K&R、BSD/Allman、GNU、Whitesmiths。对于应用程序,我通常选择BSD/Allman风格,因为它是Windows和Linux下都常用的代码风格。点击New按钮,选择基础的风格后,再点击Edit按钮,进入具体的代码风格元素的设置,最后可以配置出自己习惯的代码风格。

我通常在BSD/Allman基础风格中,修改IdentationTab policySpacesonly,意思是:在键入Tab时,实际输入的是Tab宽度的空格。使用空格代替Tab,对于用不同编辑器显示源代码时的效果,以及拷贝、粘贴源代码后仍保持原有缩进效果很有用。

自己配置的代码风格,可以在代码风格Edit对话框中,点击Export按钮导出保存成文件。在Code Style界面中可以用Import导入以前保存的风格。

技巧

如果编辑已有的源文件,但里面的代码风格和新加入的代码风格不同,怎样快速地把以前的代码转换为现在的风格?先选择要转换的代码文本,然后在右键菜单中选择:SourceFormat,或快捷键Ctrl+Shift+F,就可以将选择的代码文本转换为当前的代码风格。

自动生成代码的模板

自动生成代码的模板在:PreferencesC/C++Code StyleCode Templates 中设置。

自动生成代码的模板有三个级别:注释(Comments)、代码(Code)、文件(Files)。在代码模板里可以使用很多Eclispe内置宏,比如:${date},表示当前的日期;${user},表示当前的系统登录用户。Eclipse在自动生成代码时,会将这些宏扩展成实际对应字符串。在:C/C++Template Default Values 中,有4个宏:message、sourceDir、author、copyright,可以设置它们的值,在创建HelloWorld工程时,自动生成的代码文件就会使用这里的宏。

C/C++代码语法高亮设置

C/C++代码语法高亮在:PreferencesC/C++EditorSyntax Coloring 中设置。

Syntax Coloring中,CDT将语法元素分为四类:Code、Assembly、Comments、Preprocessor。选择特定的语法元素后,可以更改它使用的字体颜色、斜体、加粗、下划线效果等,设置后可以立即在下面的Preview中预览代码语法高亮效果。

我使用的代码语法高亮方案,参考我的这篇文章:我的C/C++代码语法高亮方案

 

代码自动完成

CDT默认的C/C++代码自动完成功能配置已经很好用了,只需要进行调整即可。

自动完成的代码模板在:PreferencesC/C++EditorTemplates 中设置。注意,这里的模板功能和Code Style中Code Templates之间的区别:Code Templates是Eclipse自动生成代码的模板,而这里的Templates是程序员输入一部分代码后,要求Eclipse自动完成、补全所有代码的模板。

可以自己新建,或更改已有的自动完成代码模板。自动完成代码模板分两类:

C/C++代码的自动完成。此时模板的Context为C/C++,包括C/C++语句、代码块等的自动完成。比如:建立一个Name为main的模板,在Pattern中输入以下代码文本模式:

查看源代码

 

打印帮助

1

intmain(intargc,char** argv)

2

{

 

3

    ${cursor}

 

4

    return0;

 

5

}

 

编辑C/C++源代码时,输入main(即模板的Name),然后按快捷键Alt+/,就可以直接插入上面的main函数代码块。${cursor}是个宏,表示当这段代码插入完成之后,编辑光标停留的位置。

注释的自动完成。此时模板的Context为Comment,而且只在注释区域内进行自动完成。

注意:CDT中默认的模板都是K&R的代码风格,喜欢BSD/Allman风格的话,需要修改一下。

自动完成代码模板配置好后,接下来需要调整自动完整功能的配置,位置在:PreferencesC/C++EditorContent Assist

首先需要将Content AssistAdvanced中的:Select the proposal kinds contained in the 'default' content assistlist 中的TemplateProposals选择上。这里的意思是:将Template Proposals放入Default Proposals中,Template Proposals是指模板候选代码完成的类别,即使用上面提到的在Templates 中设置的内容来进行候选完成代码的生成。另外还有其它类别的候选完成代码:Help Proposals、Parsing-based Proposals、Word Proposals。

然后可以在Content Assist中的Insertion中,将Insert single proposals automatically去掉,这个选项的意思是:当只有一个候选完成功能(Proposal)匹配当前文本时,直接插入文本到文件中,而不给用户选择的机会。

代码自动完成的启动方法:光标定位到要自动完成的文字后,选择右键菜单中的:SourceContent Assist,或快捷键Alt+/,此时会弹出完成代码上下文菜单,里面列举了候选的完成代码,用户选择一个后,就会插入这段完成代码到源文件中。如果在弹出完成代码菜单的情况下,继续按快捷键Alt+/,菜单中的内容就会在不同类别的候选完成代码间切换,切换的顺序可以在Content AssistAdvanced中的:Content assist cycling 中设置。代码自动完成效果如下:

 

名字高亮显示

名字:指C/C++代码中的变量名、函数名、宏名、自定义类型名等实体名字。名字高亮显示(Mark Occurrences):指光标停在一个名字上后,在这个名字的作用域内,高亮显示所有出现的这个名字。

名字高亮显示的在:PreferencesC/C++EditorMark Occurrences 中设置。选择:Mark occurrences of the selectedelement in the current file 选项,就会启动名字高亮显示功能。另外有个:Keep marks when theselection changes 选项,它的意思是:光标第一次定位到某个名字上时,高亮显示这个名字,此时如果将光标移到另外的非其它名字的位置,先前的那个名字依然被高亮显示,直到光标移到其它名字上时,才会取消原来名字的高亮显示,转而高亮显示新定位的名字。

另外,还可以在Eclipse的工具条中点击按钮:,来立即启动/停止名字高亮显示功能。

名字高亮显示所使用的颜色在:PreferencesGeneralEditorsText EditorsAnnotations中设置,选择Annotation types中的C/C++ Occurrences,然后设置颜色即可,我通常将它设置为正黄色(RGB(255,255,0))。

名字高亮显示的效果如下:

 

任务标记

CDT中使用任务(Task)来管理开发计划,任务是Workspace级别的:一个Workspace中所有Project的任务都在Tasks窗口中列出,Tasks窗口可用菜单WindowShowViewTasks调出。

任务标记(Task Tag)是一种特殊格式的C/C++代码注释,CDT会扫描并识别这种注释,生成一条任务。由任务标记生成的任务,在Task窗口中双击后,代码编辑器会立即跳转到对应的任务标记注释位置,并在那行注释前显示图标:。这个功能的意义在于:先记录发生问题的代码位置,方便以后解决问题。

任务标记的注释格式在:PreferencesC/C++>→Task Tags 中设置,默认的任务标记格式是:注释中包含"TODO"。任务标记的使用效果如下:

 

符号检索

符号检索是对一个工程中所有C/C++源代码中各种符号、名字引用的快速定位。目前优秀的代码编辑环境都支持符号检索,比如:VC内置的Intellisense、VC的VisualAssist X插件、SourceInsight等。目前,无论是哪种支持符号检索的编辑环境,在使用符号检索功能前,都需要对一个工程中的C/C++源代码进行扫描,生成索引数据库,例如VC的.ncb文件,就是VC的Intellisense生成的索引数据库文件。

CDT的索引数据库文件格式是.pdom,保存在Workspace的配置目录:.metadata/.plugins/org.eclipse.cdt.core 目录下,索引数据库文件名格式一般是:[Project-Name].[Random-NO].pdom。

索引数据库的生成选项在Workspace和Project中都可以配置,Project中的配置会覆盖Workspace中的配置。Workspace中索引的配置在:C/C++Indexer 中。

Indexer中,可以选择三种建立索引的基本方式:Fast C/C++ Indexer(快速索引)、Full C/C++ Indexer(完全索引)、No Indexer(无索引),一般选择FastC/C++ Indexer,就足够对一般工程的代码进行准确地符号检索了。如果觉得使用Fast C/C++ Indexer时,有些符号仍然不能正确检索,可以将选项Index all files选择上,不过这样建立的索引文件就会变大,建立索引的过程也会变慢,所以不建议在Workspace的索引配置里选择这个选项。

Files to index up-front中输入的文件名,会在建立索引时首先被扫描,默认是:stdarg.h、stddef.h、sys/types.h。

Indexing strategy可以设置建立索引活动的策略:

·        Automatically update the index:自动更新索引。

·        Update index immediately after every file-change:当文件内容改变后,立即更新索引。

CDT的索引建立过程本来就有些慢,而上面两个选项会使建立索引活动变得更频繁。不过为了在最新的代码文件中使用准确的符号检索,一般将这两个选项选择。

Build configuration forthe index中,可以指定索引配置如何应用到工程配置项中:

·        Use active build configuration:使用活动的工程配置项建立工程的索引。我一般使用这个选项,因为工程配置项会影响到C/C++源代码和符号检索,比如:一段代码受工程配置项中的宏定义影响,而使用不同的内容。

·        Use the build configuration specified in theproject's indexer settings:在Workspace中不指定被索引的工程配置项,将该任务放到Project的配置中设置。

使用符号检索的方法有多种。最简单、最常用的是跟踪符号到其定义或声明,方法是:按住Ctrl键,然后点击某个符号,就会跳转到其定义或声明位置。

 

备份与移植Workspace配置

好不容易设置起来的Workspace配置,怎样将它备份呢?怎样将一个已设置好的Workspace配置,应用到所有Workspace上呢?

对一个Workspace配置的备份其实就是备份Workspace的配置目录.metadata:先在Eclipse中删除该Workspace的所有Project;然后在关闭Eclipse,在.metadata中搜索所有跟Project有关的文件,删除掉,比如工程的索引数据库文件.pdom;最后备份这个.metadata目录即可。

当要使用以前备份好的Workspace配置时,将备份的.metadata目录拷贝到期望建立Workspace的目录下,然后启动Eclipse时,在Workspace Launcher对话框中,输入那个Workspace目录的位置,就可以让Eclipse使用已设置好的Workspace配置。

Workspace Launcher对话框中显示的最近打开的Workspace,保存在Eclipse的程序配置目录中的:configuration/.settings/org.eclipse.ui.ide.prefs 文件中。org.eclipse.ui.ide.prefs中的RECENT_WORKSPACES值记录了最近打开的Workspace,如果要清空最近打开的Workspace记录,将它的值设置为空即可。

 

Eclipse的Project配置

C/C++Projects窗口中示了当前Workspace的所有Project,C/C++ Projects窗口可以使用菜WindowShow ViewC/C++ Projects出。

定一个Project后,可以用菜ProjectProperties,或右中的Properties(快捷Alt+Enter出特定工程的配置对话框。

工程配置会承Workspace中的一些配置,如果工程配置中改变这部分配置的,工程的置会覆盖掉Workspace置。在工程配置中C/C++ General下有些配置有:Enable project specificsettings选项,启动这选项后,会在工程目.settings,里面记录了工程特定的置。

工程的工具集配置

Eclipse-CDT默认能够建立4种工程类型:ExecutableShared LibraryStatic LibraryMakefile Project

如果希望Eclipse-CDT,通过扫描工程中的源文件,帮你自动生成makefile,则可以选择前3种工程类型,这种情况通常应用在使用Eclipse新建一个工程时。

如果希望使用手工编辑makefile的方式,来管理工程的生成,可以选择MakefileProject的工程类别。

实际上,只要在工程配置中进行适当设置,Eclipse的每一种工程类别都能用来管理外部已存在的工程。

当我使用Eclipse新建一个工程时,通常使用:CDT自动生成makefile,配合外部make工具的方式。配置方式如下;

建立一个Executable类型的工程。在工程配置中的C/C++ BuildTool Chain Editor中的Current toolchain可以指定工程特定的工具集,例如:MinGW GCC。在Current builder中,将默认的:CDT Internal Builder(CDT内建的make工具),改为:Gnu Make Builder。最后在Select Tools中可以替换工具集中的每种工具。

6、Android NDK 的安装

安装NDK的步骤:

1、从http://developer.android.com/sdk/ndk/index.html网页上的表格下载适合你电脑开发环境的版本。

2、下载之后利用解压工具解压下载后的文件,解压后,NDK的文件就在android-ndk-<version>.这样的目录下面

7、Debian 下git工具的安装

 

 

SSH Signature

 

 

 

Installing and Setting Up Gitorious on RHEL 5 Marko Peltola

 2010-06-15 (Updated:2010-08-11)

Verso Project

 Department of MathematicalInformation Technology

 University of Jyväskylä

Gitorious is an open source application originally

 developed for hosting opensource projects in git repositories. This document

 describes how to installGitorious on Red Hat Enterprise 5 (RHEL 5) server.

This guide also covers how to install the services Gitorious isdependent on,

 including:

 •Web server (Apache)

 

•Database server (MySQL)

 

•Ruby (Enterprise Edition)

 The guide is based on:

 •Setting up Gitorious on yourown server

 

•rough notes for installing gitorious on fedora 11

 The installation guide istested with customized version of Gitorious named

 YouSource, version 1f2c62 (Githash). Though the installation process is the

 same on the both versions.

All the commands are meant to run as root user, if not mentionedotherwise.

Install Required Packages Gitorious needs a lot of software:

yum install -y git git-svn pcre pcre-devel zlib zlib-devel sendmail ;

yum -y groupinstall "Development Libraries""Development Tools" ; 

yum install -y libssh2 libssh2-devel openssh openssh-server \ 

    memcached libyamllibyaml-devel ImageMagick ImageMagick-devel \ 

    apr-devel uuidjava-1.6.0-openjdk readline-devel glibc-devel \ 

    openssl-devel gcc-c++gcc-c++ zlib-devel openssl-devel readline-devel \ 

    sphinx

 Install Ruby and RubygemsGitorious runs on a variety of Rubys (>= 1.8.6). If you want to use thebasic

 Ruby, you can install it with:

yum install -y ruby ruby-devel rubygems

 If you want to install RubyEnterprise Edition, you have to download the source

 tarball. The source tarballcontains a cross-platform installer. This guide is

 based on Ruby Enterprise so Irecommend to use it.

wgethttp://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz

tar xzvf ruby-enterprise-1.8.7-2010.01.tar.gz 

./ruby-enterprise-1.8.7-2010.01/installer

 Install Required Gems Gitoriousrequires a lot of gem packages.

gem update --system

gem install --no-ri --no-rdoc rails mongrel mime-types \ 

    textpow chronic ruby-hmacdaemons mime-types oniguruma passenger \ 

    textpow chronicBlueCloth  ruby-yadis ruby-openid geoipultrasphinx \ 

    rspec rspec-rails RedClothechoe hoe diff-lcs stompserver json mysql

 Important! Latest version ofrack wasn’t compatible with our testing

 environment, you may need touse version 1.0.1 instead.

gem install --no-ri --no-rdoc -v 1.0.1 rack

 Install and Configure MySQLGitorious should work with any SQL server, but it’s only tested with MySQL.

 •Install MySQL

 

yum install mysql mysql-server mysql-libs mysql-devel

 

 •Start the service

 

service mysqld start

 

 •Set a password for root user.Replace <password> with your own password.

 

mysqladmin -u root password '<password>'

 

 Set Up git User Gitorious needsa specific user which runs the services. Here it’s named git.

 Gitorious uses SSH keys inauthentication in Git push. The git user needs to

 have a home directory, wherethe SSH keys are saved.

adduser --create-home git

 Because git push isauthenticated via git user, the git user must have a ssh

 access to the server. So addgit user to AllowGroups in /etc/ssh/sshd_config.

Clone the Gitorious Repository Go to the directory where you want todownload the application, for example to

 /var/www. Use git to downloadGitorious.

git clone git://gitorious.org/gitorious/mainline.git gitorious

 Or if you want to installcustomized version of Gitorious named YouSource,

(currently only available inside the Jyväskylä University network):

git clone git://versotest.it.jyu.fi/verso/gitorious.git

 Make a symbolic link ofgitorious script to /usr/local/bin/.

ln -s /var/www/gitorious/script/gitorious /usr/local/bin/gitorious

 Create the Directories forRepositories and Tarballs Make the directories, where the git repositories andtarballs are saved.

mkdir /var/git

mkdir /var/git/repositories 

mkdir /var/git/tarballs 

mkdir /var/git/tarball-work

 Change the owner of these andthe application directories to git user.

chown -R git:git /var/git /var/www/gitorious

 Install a Web Server Gitoriousis a web application, so you need a web server. Here we install

 Apache, but you can use someother web server as well.

yum install -y httpd httpd-devel

 Install also the mod_xsendfilemodule to get source tarball downloading working.

wget http://tn123.ath.cx/mod_xsendfile/mod_xsendfile.c

apxs -cia mod_xsendfile.c

 Install and Configure PassengerInstall Phusion Passenger module to simplify Rails application deployment.

/opt/ruby-enterprise/bin/passenger-install-apache2-module

 Follow the instructions asprovided by the installation script.

Edit Apache configuration file /etc/httpd/conf/httpd.conf and add thelines

 the installation script recommend,something like this:

LoadModule passenger_module/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so

PassengerRoot/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.11 

PassengerRuby /opt/ruby-enterprise/bin/ruby

 In the same file setDocumentRoot to <your-gitorious-root>/public, for example

 /var/www/gitorious/public, andset your ServerName (ours is versotest.it.jyu.fi).

 

 

  ServerName versotest.it.jyu.fi

  DocumentRoot/var/www/gitorious/public

 

  # Enable X-SendFile forGitorious repo archiving to work 

  XSendFile on 

  XSendFileAllowAbove on 

 

  <Directory/var/www/gitorious/public> 

     AllowOverride all 

     Options -MultiViews 

  </Directory> 

 

 

 

  ServerName versotest.it.jyu.fi

  DocumentRoot/var/www/gitorious/public 

 

  <Directory/var/www/gitorious/public> 

     AllowOverride all 

     Options -MultiViews 

  </Directory> 

 

 Restart Apache and after thatPassenger should recognize the application and

 start it when accessing the webpage through a web browser.

Set Up Gitorious The git user runs all the Gitorious services. So fromnow on use git user:

sudo su git

 Add these lines in the end ofthe git user’s ~/.bashrc file so that git user

 can run ruby programs. Changethe directory to match your Ruby installation

 directory.

export RUBY_HOME=/opt/ruby-enterprise

export GEM_HOME=$RUBY_HOME/lib/ruby/gems/1.8/gems 

export PATH=$RUBY_HOME/bin:$PATH

 Load new paths as a git user:

source ~/.bashrc

 Make authorized_keys File Whensomeone tries to push to a repository through Gitorious, the user will be

 looked up in the git user’s~/.ssh/authorized_keys. If the user is found here,

 the ssh connection is handledby the git-daemon process. We have to create this

 file, but Gitorious will maintainit for us.

Make sure the permissions on authorized_keys are 600 and ~/.ssh are700.

mkdir ~/.ssh

chmod 700 ~/.ssh 

touch ~/.ssh/authorized_keys 

chmod 600 ~/.ssh/authorized_keys

 Configuration Next go to yourGitorious root dir (for example cd /var/www/gitorious) and

 make a directory for pid files.

mkdir -p tmp/pids

 Make all the Gitorious scriptsexecutable.

chmod ug+x script/*

 Copy the configuration samplefiles and edit the settings. The files includes

 good instructions.

cp config/database.sample.yml config/database.yml

cp config/gitorious.sample.yml config/gitorious.yml 

cp config/broker.yml.example config/broker.yml

 If you installed customizedYouSource, you have to edit these files too:

cp config/email.yml.example config/email.yml

cp script/ldap_settings.py.template script/ldap_settings.py

 Install the remaining gems:

sudo rake gems:install

 Create the database and schema:

rake db:create RAILS_ENV=production

rake db:migrate RAILS_ENV=production

 Build the search index andstart the search daemon:

rake ultrasphinx:configure RAILS_ENV=production

rake ultrasphinx:index RAILS_ENV=production 

rake ultrasphinx:daemon:start RAILS_ENV=production

 Schedule Sphinx search engineto index the site automatically. Add to the

 crontab, using crontab -e, thefollowing line:

* * * * * cd /var/www/gitorious &&/opt/ruby-enterprise/bin/rake ultrasphinx:index RAILS_ENV=production

 Scripts Copy git-daemon andgit-ultrasphinx from doc/templates/centos to

 /etc/init.d/ as root user.

You have to create gitorious-poller and stomp scripts on your own.

gitorious-poller Example File: #!/bin/sh

# poller       Startup scriptfor Gitorious's poller 

# chkconfig: - 86 15 

# description: Gitorious's poller script is simple worker that polls\ 

#              tasks from stompserver queue and executes them. 

# processname: poller

 

/bin/su - git -c "cd /var/www/gitorious; RAILS_ENV=production./script/poller $@"

 stomp Example File: #!/bin/sh

# stomp        Startup scriptfor stomp server  

# chkconfig: - 85 15 

# description: Stomp server is simple task queue server that \ 

#              uses stompprotocol.      

# processname: stomp 

# config: /etc/stompserver.conf

 

/bin/su - git -c "cd /var/www/gitorious; RAILS_ENV=production;stompserver -C /etc/stompserver.conf $@"

 Start the Services Go to/etc/init.d/ and give the scipts execute permissions:

sudo chmod 755 git-daemon git-ultrasphinx gitorious-poller stomp

 Add services to startautomatically on boot:

chkconfig --add stomp

chkconfig --add git-daemon 

chkconfig --add gitorious-poller 

chkconfig --add git-ultrasphinx 

chkconfig --add memcached

 

chkconfig stomp on 

chkconfig git-daemon on 

chkconfig gitorious-poller on 

chkconfig git-ultrasphinx on 

chkconfig memcached on

 Now you can start the services:

service git-ultrasphinx start

service stomp start 

service memcached start 

service gitorious-poller start 

service git-daemon start 

service httpd restart

 Now you should have Gitoriousup and running! Go to your web page through a

 browser and start usingGitorious.

 

 

 

 

Subversion

subversionis an open source version control system.

Createsvn repository: #sudo svnadmin ~/Health/SourceCode

usage: svn <subcommand> [options] [args]

 

Type 'svn help <subcommand>' for help on aspecific subcommand.

 

Type 'svn --version' to see the program versionand RA modules

 

  or 'svn--version --quiet' to see just the version number.

 

 

 

Most subcommands take file and/or directoryarguments, recursing

 

on the directories.  If no arguments are supplied to such a

 

command, it recurses on the current directory(inclusive) by default.

 

 

 

Available subcommands:

 

   add

 

   blame(praise, annotate, ann)

 

   cat

 

  changelist (cl)

 

  checkout (co)

 

   cleanup

 

   commit(ci)

 

   copy(cp)

 

   delete(del, remove, rm)

 

   diff(di)

 

   export

 

   help(?, h)

 

   import

 

   info

 

   list(ls)

 

   lock

 

   log

 

   merge

 

  mergeinfo

 

   mkdir

 

   move(mv, rename, ren)

 

   propdel(pdel, pd)

 

  propedit (pedit, pe)

 

   propget(pget, pg)

 

  proplist (plist, pl)

 

   propset(pset, ps)

 

   resolve

 

  resolved

 

   revert

 

   status(stat, st)

 

   switch(sw)

 

   unlock

 

   update(up)

 

 

1、Preference的key作用是什么。

理解:

 

2、内容只能够为字符、数字、下划线吗?

理解:在xml里面设置的值是区分大小写的,但是xml的文件标题是不能用大写字母的因为规定。

 

3、xml名称只能够是小写字母、下划线、小数点这三类中的组合。

理解:这是甲鱼的臀部规定。没有什么可以解释的,以后注意就行了。

 

4、xmlns的作用是什么,什么时候需要用到这些东西。

理解:

 

5、重编译android源码的步骤:

第一步:

 

 

第二步:

 

 

第三步:

 

第四步:


问题:申明并初始化日志包时,为什么要加static。

理解:这里需要说明一下,其实每一个类只要申明同一个标题即可,因为这样程序方便书写,至于要加static,就是为了其它类可以直接访问而不需要实例化。

 

问题:为什么PreferenceActivity用setLayoutView程序不会报错,但是运行会出错?

理解:因为preferenceActivity是继承于Activity,而Activity是用setLayoutView来把配置文件加载到UI里面的。所以程序不会报错,但是程序运行会出错。

 

问题:Handle和Broadcast的差别是什么

理解:Handle是处理发送消息的一种机制,它是连接Runnable和Activit的一个桥梁。  它一般是主线程的一部分,用于处理主线程和子线程之间通信的问题。Android启动时会启动一个主线程即UI线程,主线程管理UI进行事件分发,此时我需要联网读取数据或者处理一个耗资源的事件时,不可能在主线程中操作。这时,开辟一个子线程来处理这些事物,如果主线程需要子线程处理的相关信息的时候就需要Handle来进行沟通和传递。

比如说播放电影,主界面在点击播放的文件以后,后台就需要进行缓冲后面的数据并且进行解码。电影需要进度条表示播放的位置这个时候如果在android中就可以通过Handle把缓冲多少的数据显示在播放器里面。

 

问题:capacity和size的差别

理解:capacity代表缓冲区的容量,size代表元素的个数。

 

问题:vector和arraylist的差别是什么

理解:

 

问题:mm Linux的指令的作用

理解:

 

问题:finish()的逻辑流程

理解:

 

问题:分析Preference的click监听和change监听

理解:这两个分别是一对回调函数,只有在Preference的某些信号发出以后才会执行这些回调函数。

 

问题:分析minHeight的相关内容

理解:

 

问题:TabActivity插入Activity

理解:

 

问题:List  ArrayList  Vector的区别是什么

理解:

 

问题:static的作用域是什么范围,final、static的意义各是什么?

理解:java中static创建的域会一直占用着系统开辟的一块内存单元,所有的对象都是共享这一块内存单元,当程序结束以后,这块内存区域会被释放,android中,如果需要所以对象或者其他类的对象能够共享同一个信息,就需要用static,但是对于每个对象自己专属的信息就应该不用static。final作为类修饰符说明此类不能够被其他类继承,作为方法修饰符说明此方法。static是一种静态的方法,它是静态绑定在所修饰的类里面的。

 

问题:如何在新构建的Preference里面加载新UI,如果不重写父类会有怎样的一个结果。

理解:通过setLayoutResource来加载构建的UI,但是在新构建的Preference需要将父类用上面这个函数进行构建,

 

问题:如何在重构Preference里面重写onPreferenceClickListener使得不仅监听右边的checkBox还可以实现其他的操作

理解:

 

问题:为什么要用try..Exception.以及他们使用的逻辑是什么.

理解:

 

问题:一个android可否有多个package,package的意义是什么

理解:一个android可以有多个package,一个package就相当于一个组,

 

问题:Activity显示Dialog的回调情况是怎样处理。

理解:如果Activity中需要有Dialog显示的话就会回调onCreateDialog这个函数

 

问题:为什么在真实环境下编译程序的时候@Override要删除?

理解:其实写@Override是编译器用于纠错的一种方式,如果加了@Override后程序与父类的不同的地方,程序很提示错误。但是在android源码编译的时候是不支持@Override的,因为这个并不是java的关键字。所以以后程序在eclipse下程序做完以后要编译成为apk,就把所有的@Override都删除。注意:在eclipse写程序的时候一定要用这些东西辅助编程,因为这样编码的效率很高,等需要在编译机上运行的时候再把所有的@Override去除。

 

问题:LayoutInflater的作用。

解答:

 

问题:用abstract修饰类的意义是什么

解答:abstract修饰的类是一种只有申明的抽象类,这种类型的类不能够有实例,也就是说他是一个父类,所有的子类都是来实现这个父类的所有具体的类,他的子类可以有实例,这就是多态性的体现,

 

问题:用interface(接口)定义的方法用途是什么?

解答:接口的定义只有方法的申明而没有方法的实现,但是接口的申明的方法必须被实现接口的类支持。所以这就能解释为什么要写implementsintereface,在实现接口的时候需要写如何实现这种接口的具体操作。

 

问题:ListAdapter的作用是什么

解答:

 

问题:HashMap的作用和意义

解答:

 

问题:windowsManager的作用是什么

解答:

 

问题:managerQuery的作用是什么

解答:

 

问题:object类的作用以及里面方法的具体用途。

解答:object类是所有类层次的根,所有类都直接或间接地继承object类,所以一个object类型的变量可以引用任何对象,无论是类的实例还是数组

 

问题:异常定义,使用意义。

解答:

 

问题:设置Activity的方向为什么要在AndroidManifest.xml设置screenOrientation,作用是什么?

解答:因为在Activity.java里面当此activity没有父窗口的时候,他的orientation就是默认的值,这就无法取到真实当前的ScreenOrientation。才会无法判断,所以要在activity里面设置当前的screenOritation,这样就可以完成上述的内容了。

 

问题:文件系统操作

解答:

 

问题:java的内部嵌套类是怎么回事?

解答:内部嵌套类包括静态嵌套和非静态嵌套。

 

问题:Hashtable是什么东东?

解答:

 

问题:FileInputStream和FileWriter的区别是什么?

解答:一个是字节流,一个是字符流两种不同的流文件

 

问题:Layout_weight是怎么回事?

解答:相当于是一个比重,不是view的尺寸,比重越大,剩下的空间占用的也就越大,比重越小,他就会显示出本身的大小。

 

问题:Differences between android units

解答:There are some units in android displaysystem.that is dp(device Independent pixel) , sp(scale pixel) , px(pixel) ,in(inches)、pt(points)、mm(millimeters).

 

问题:指向函数的指针

解答:

 

问题:什么是opp和ftp,两者的差别在哪里。

解答:

 

问题:什么是回调,如何触发回调函数。

解答:

 

问题:Adapter的作用

理解:相当于配对器,里面存放一些内容和数据,用于适配这个控件


问题:When the plat gives me correspond :insuffcient permission in device

解答:


问题:Why we need "synchronized" ,What's the function of the keyword.

解答:

 

问题:StringBuffer cannot regard as functionparameters

解答:Wheni want to save a string to a class , But unfortunately ,the variable in thesubfunction is proved to be null.So the reason is what?

 

问题: What's modifier of the embeded class

解答:

 

问题: In theBroadcastReceiver Function,why we should check the existence of intent ?

解答:

 

44 why bt_server cannot start ?

bt_server is an executive binary

 

ANDROID(JAVA) BinderMechanism

1 IPC(Inter ProcessCommunication)

 

2 Binder Mechanism

Itcontains several elements , as follows Binder Device,Service Manager , Server ,Client , Object agent .

BinderDevice:

Binderis a character drive device which is located in /dev/binder .It is the key partof the IPC system . Through it ,The client's server agent sent request signalto  server.then ,server will return theresult to client server agent. (binder.c will solve more problems if you wantto get deep study)

ServiceManager:

 

Server

Here, I should distinguish System server from SDK server .

 

 

 

 

问题: What is the service andHow services work in the android system .

解答:

 

问题: What is the function ofthe key word-”synchronized”

解答: 


问题:如何理解intent中的所添加的FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT

解答:根据官方解释应该理解为在系统启动完毕之后才去检查是否代码注册,也就是说系统启动之后才回去发给代码注册的接受者。

 

 

 

         

           

 

 

            

原创粉丝点击