itoa()

char* itoa(int val, int base){
 
     static char buf[32] = {0};
 
     int i = 30;
 
     for(; val && i ; --i, val /= base)
 
          buf[i] = "0123456789abcdef"[val % base];
 
     return &buf[i+1];
 
}


Powerd by: http://tohtml.com/

make 命令 & makefile

makefile syntax

  • dependencies (相依性項目)
    • one target (目標項目)
    • some source code files
    • (target), (semicolon), (space or tab), ....., (source code files), (space or tab), .....
    • e.g. all: myapp myapp.l
  • rules (法則)
    • the rules illustrate how to generate a target
    • (tab)
    • the rules muse be on the same line
  • comment (註解)
    • (#)
  • macro (巨集)
    • define the macro => MACRONAME = value
    • access the macro => $(MACRONAME), ${MACRONAME}
  • -
    • make will ignore the error
    • e.g. -mkdir
    • e.g. -rm -r
  • @
    • make will not output the executed command on standard output
  • #這是makefile的格式(註解) 
    [target]: [dependency] [dependency] 
    [TAB][rule] 
    [TAB][rule] 
    [target]: [dependency] 
    [TAB][rule] 

make options


-k : 會讓make再遇到錯誤之時,仍然繼續執行而不會停在第一個問題點。可以利用這個選項找出發生問題的原始碼檔案。

-n : 告訴make只列出要進行的工作,而不會真正去執行它。

-f : tell the make to use the as a makefile. Otherwise, the make will use the makefile, Makefile (recommend).

-p : 要求 make 印出內建法則

-j3 : use the 3 cores 

Automatic Varaiables


$@ :  The name of the current target 

$% :  The filename element of an archive member specification

$<: first="" he="" name="" nbsp="" of="" p="" prerequisite="" the="">
$?:    The names of all prerequisites that are newer than the target, separated by spaces,代表須要重建(被修改)的相依性項目

$^:     The names of all prerequisites, separated by spaces. This is list has duplicated names removed.

$+:     Similar to $^, except $+ includes duplicateds.. This variable was created for specific situations such as arguments to linkers where duplicated values have meaning.

$*:    The stem of the target filename. A stem is typically a filename without its suffix. Current dependencies without the extension (副檔名)


  1. define the marcro : 1) make CC=c89    2) make "CC = c89"
  2. Use the all as the first target in makefile
  3. all (target)
  4. install (target)
  5. uninstall (target)
  6. clean (target)


GNU gcc

gcc -MM : generate a dependency list to make


Conventional Macros (common built in rules of makefiles)

typing "make −p" to print out the defaults
ARArchive−maintaining program; default is `ar'.
ASProgram for compiling assembly files; default is `as'.
CCProgram for compiling C programs; default is `cc'.
COProgram for checking out files from RCS; default is `co'.
CXXProgram for compiling C++ programs; default is `g++'.
CPPProgram for running the C preprocessor, with results to standard output; default is `$(CC) -E'.
ARFLAGSFlags to give the archive-maintaining program; default is `rv'.
ASFLAGSExtra flags to give to the assembler when explicitly invoked on a `.s' or `.S' file.
CFLAGSExtra flags to give to the C compiler.
CXXFLAGSExtra flags to give to the C compiler.
COFLAGSExtra flags to give to the RCS co program.
CPPFLAGSExtra flags to give to the C preprocessor and programs, which use it (such as C and Fortran compilers).

Conditional Directives

  • ifeq
  • ifneq
  • ifdef
  • ifndef
  • else
  • endif
e.g.
ifeq (arg1, arg2)
ifeq 'arg1' 'arg2'
ifeq "arg1" "arg2"
ifeq "arg1" 'arg2'
ifeq 'arg1' "arg2" 

相關文件


Linux 壓縮與解壓縮

.tar
解壓:tar xvf FileName.tar
壓缩:tar cvf FileName.tar DirName
(注:tar是包裹(把多個檔案合成一個),不是壓缩!)
---------------------------------------------
.gz
解壓1:gunzip FileName.gz
解壓2:gzip -d FileName.gz
壓缩:gzip FileName
.tar.gz
解壓:tar zxvf FileName.tar.gz
壓缩:tar zcvf FileName.tar.gz DirName
---------------------------------------------
.bz2
解壓1:bzip2 -d FileName.bz2
解壓2:bunzip2 FileName.bz2
壓缩: bzip2 -z FileName
.tar.bz2
解壓:tar jxvf FileName.tar.bz2
壓缩:tar jcvf FileName.tar.bz2 DirName
---------------------------------------------
.bz
解壓1:bzip2 -d FileName.bz
解壓2:bunzip2 FileName.bz
壓缩:未知
.tar.bz
解壓:tar jxvf FileName.tar.bz
壓缩:未知
---------------------------------------------
.Z
解壓:uncompress FileName.Z
壓缩:compress FileName
.tar.Z
解壓:tar Zxvf FileName.tar.Z
壓缩:tar Zcvf FileName.tar.Z DirName
---------------------------------------------
.tgz
解壓:tar zxvf FileName.tgz
壓缩:未知
.tar.tgz
解壓:tar zxvf FileName.tar.tgz
壓缩:tar zcvf FileName.tar.tgz FileName
---------------------------------------------
.zip
解壓:unzip FileName.zip
壓缩:zip FileName.zip DirName
---------------------------------------------
.rar
解壓:rar a FileName.rar
壓缩:rar e FileName.rar


rar請到:http://www.rarsoft.com/download.htm 下載!
解壓後請将rar_static拷貝到/usr/bin目錄(其他由$PATH環境變數指定的目錄也可以):
[root@www2 tmp]# cp rar_static /usr/bin/rar
---------------------------------------------
.lha
解壓:lha -e FileName.lha
壓缩:lha -a FileName.lha FileName

lha請到:http://www.infor.kanazawa-it.ac.jp/~ishii/lhaunix/下載!
解壓後請将lha拷贝到/usr/bin目錄(其他由$PATH環境變數指定的目錄也可以):
[root@www2 tmp]# cp lha /usr/bin/
---------------------------------------------
.tar .tgz .tar.gz .tar.Z .tar.bz .tar.bz2 .zip .cpio .rpm .deb .slp .arj .rar .ace .lha .lzh .lzx .lzs .arc .sda .sfx .lnx .zoo .cab .kar .cpt .pit .sit .sea
解壓:sEx x FileName.*
壓缩:sEx a FileName.* FileName

sEx只是調用相關程序,本身並無壓缩、解壓功能,請注意!\r
sEx請到:http://sourceforge.net/projects/sex下載!
解壓后請将sEx拷贝到/usr/bin目錄(其他由$PATH環境變數指定的目錄也可以):
[root@www2 tmp]# cp sEx /usr/bin/ 

Remove sun-java6-jdk on UBUNTU

SDK instal and path set up  

http://wallyjue.blogspot.com/2011/04/ubuntu-1004java-jdk-15.html

Remove java
$sudo apt-get remove sun-java6-jdk
$sudo apt-get remove sun-java6-jre
$sudo apt-get remove sun-java6-bin

Introduce the Linux Directories


If you look at the Linux file hierarchy, you find the following :
  • /bin - common binaries
  • /sbin - Binaries used for system administration are placed here.
  • /boot - static files of the boot loader. Usually it contain the Linux kernel, Grub boot loader files and so on.
  • /dev - device files such as your CD drive, hard disk, and any other physical device. (In Linux/Unix, the common premise is that everything is a file).
  • /home - user home directories are found here. In unices like FreeBSD, the home directoriesare found in /usr/home. And in Solaris it is in /export. So quite a big difference here.
  • /lib - Essential shared libraries and kernel modules
  • /mnt - temporary mount point useful for when you insert your USB stick and it gets mounted under /mnt. Though in Ubuntu and the likes, it is usually mounted under /media.
  • /var - variable data, such as logs, news, mail spool files and so on which is constantly being modified by various programs running on your system.
  • /tmp - temporary files are placed here by default.
  • /usr - the secondary hierarchy which contain its own bin and sbin sub-directories.
  • /etc - Usually contain the configuration files for all the programs that run on your Linux/Unix system.
  • /opt - Third party application packages which does not conform to the standard Linux file hierarchy can be installed here.
  • /srv - Contains data for services provided by the system.

Problem: xxx is not in the sudoers file

sudo时提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权限使用sudo,我们只要修改一下/etc/sudoers文件就行了。下面是修改方法:

1)进入超级用户模式。也就是输入"su -",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用)
 

2)添加文件的写权限。也就是输入命令"chmod u+w /etc/sudoers"。
 
3)编辑/etc/sudoers文件。也就是输入命令"sudo gedit  /etc/sudoers",输入"i"进入编辑模式,找到这一 行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(这里的xxx是你的用户名),然后保存(就是先按一 下Esc键,然后输入":wq")退出。 
4)撤销文件的写权限。也就是输入命令"chmod u-w /etc/sudoers"。

Install repo

Problem:
-----------------------------------------------------------------------------------------------------------------------------
fatal: unable to connect a socket


Resolution:
-----------------------------------------------------------------------------------------------------------------------------
會出現這個問題是因為Android git   Server的DNS查詢回應太慢的關係可依照下列方法解決
1.  ping android.git.kernel.org ,將結果的IP記錄下來
2.  更改系統的hosts, 將android.git.kernel.org與IP之對照表建立起來
     方法:sudo gedit /etc/hosts 新增一行 IP address 對照到 android.git.kernel.org
3. 修改專案目錄下的  .repo/manifest.xml, 將android.git.kernel.org 替換成剛剛找到的IP
4. repo init ................................................................................


-----------------------------------------------------------------------------------------------------------------------------


http://5i01.com/topicdetail.php?f=423&t=1130384&p=1