android 爲什麼需要cygwin

 1、cygwin簡介   

Cygwin是許多軟件的集合,最初由Cygnus Solutions開發,用於各種版本的Microsoft Windows上,運行UNIX類系統。Cygwin的主要目的是通過重新編譯,將POSIX系統(例如Linux、BSD,以及其他Unix系統)上的軟件移植到Windows上. 

    cygnus當初首先把gcc,gdb,gas等開發工具進行了改進,使他們能夠生成並解釋win32的目標文件。然後,他們要把這些工具移植到windows平臺上去。一種方案是基於win32 api對這些工具的源代碼進行大幅修改,這樣做顯然需要大量工作。因此,他們採取了一種不同的方法——他們寫了一個共享庫(就是cygwin dll),把win32 api中沒有的unix風格的調用(如fork,spawn,signals,select,sockets等)封裝在裏面,也就是說,他們基於 win32 api寫了一個unix系統庫的模擬層。這樣,只要把這些工具的源代碼和這個共享庫連接到一起,就可以使用unix主機上的交叉編譯器來生成可以在 windows平臺上運行的工具集。以這些移植到windows平臺上的開發工具爲基礎,cygnus又逐步把其他的工具(幾乎不需要對源代碼進行修改,只需要修改他們的配置腳本)軟件移植到windows上來。這樣,在windows平臺上運行bash和開發工具、用戶工具,感覺好像在unix上工作。

2、NDK和cygwin

由於NDK編譯代碼時必須要用到make和gcc,所以你必須先搭建一個linux環境, cygwin是一個在windows平臺上運行的unix模擬環境,它對於學習unix/linux操作環境,或者從unix到windows的應用程序移植,非常有用。通過它,你就可以在不安裝linux的情況下使用NDK來編譯C、C++代碼了。

3.r7版本以上NDK可以不使用cygwin

http://www.kandroid.org/ndk/docs/CHANGES.html

http://developer.android.com/tools/sdk/ndk/index.html#Revisions

You can now build your NDK sources on Windows *without* Cygwin. Simply call the script 'ndk-build.cmd' from the Windows cmd.exe command-line, when in your project path. The script takes exactly the same arguments than the original ndk-build one.

Note that the Windows NDK package comes with its own prebuilt binaries for GNU Make, Awk and other tools required by the build, i.e. you shouldn't need to install anything else to get a working build system.

IMPORTANT: ndk-gdb doesn't work. You still need Cygwin to debug at the moment! This feature is still very experimental, but feel free to try it and report issues on the public forum ([email protected]) or the public bug databse (http://b.android.com). Note that all samples and unit tests succesfully compile with it.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章