看板 ck51st316 關於我們 聯絡資訊
有時會有同學問我學寫程式的問題, 常會問到哪裡有可以用來寫 C/C++ 程式的軟體(編譯器, compiler), 我會說網路上有免費的, 不過通常大部分的人恐帕都沒有興趣慢慢摸索網路上有什麼免費 的編譯器該抓那些檔案該如何安裝. 在這裡我非常簡單的介紹 DJGPP 給大家. * 在這段我盡量不用到一些專有名詞, 目的讓大家能夠很簡單的 把軟體抓回家, 安裝好, 能夠寫程式就行了 我假設你的環境是 Windows (95or98, NT我沒試過), 你知道如何操作瀏覽器, WINZIP 1.開啟瀏覽器, 網址填 http://www.ck.tp.edu.tw/~kcwu/djgppnom.zip 用 28.8K 以上的數據機約需四五Q分鐘的下載時間 2.把 djgppnom.zip 解開到 c:\ (使用支援長檔名的zip解壓縮程式, 如果不知道的話, 用 WINZIP 就可以了) (djgppnom.zip約占硬碟空間 8.5MB, 解開來約占 20MB) 3.在 c:\autoexec.bat 最後面加上這兩行 set djgpp=c:\djgpp\djgpp.env path c:\djgpp\bin;%path% 4.重新開機後, 只要輸入 rhide, 就可以開始寫程式了 操作方式很類似 Turbo C++, 有的書上有介紹 TC, 如果你沒用過, 你可能要自己玩玩看. 選單中可以找到各種功能. C 程式記得存檔副檔名 .c, C++ 則是 .cpp 程式寫好可以按 CTRL-F9 執行, 按 ALT-F5 看執行結果 5.試著寫個簡單的程式確定可以使用吧:) * 更進一步的介紹 DJGPP 是 gun c/c++ compiler(gcc) 移殖到 dos(windows) 環境的軟體, 使用 DJGPP 一些特點 -> 它是一個 32-bit 的 compiler, 且編譯出來的執行檔效率(最佳化)不錯 -> 不再有 DOS 640k 的記憶體限制 -> 他可以營造一個模擬 UNIX 的環境, 除了有 bash 及一票 UNIX 工具 可用, 寫的程式也滿容易移植到 UNIX 上 -> DJGPP 的 C compiler 符合 ANSI/ISO C 標準 -> DJGPP 的 C++ compiler 支援滿新的 C++ 標準(我不確定支援到什麼程度) DJGPP 有許多程式可選擇性安裝, 前面講的 djgppnom.zip 是我 挑選寫 C/C++ 程式所需的基本安裝, 再加上 rhide 整合開發環境, 我自己在用的則安裝了比較多的軟體, 不見得大家都會需要就是了 有興趣的可以到 http://163.13.180.5/~kcwu/ DJGPP 主要核心(djdev)已經到 2.02 版了, 我現在在用的是 2.01 * 更進一步的資訊可以參考 http://www.delorie.com/djgpp http://www.delorie.com/djgpp/v2faq/faq.html * 摘錄 FAQ 中 What is DJGPP 的部分內容 **Q*: What is DJGPP?* *A*: DJGPP is a compiler and a set of tools that let you produce 32-bit protected-mode programs which run on MS-DOS/MS-Windows machines. The originator and principal maintainer of DJGPP is DJ Delorie <dj@delorie.com>; that's where the "DJ" in "DJGPP" comes from. However, anybody is welcome and encouraged to contribute. Programs compiled with DJGPP, and all development tools provided as part of DJGPP, look on the outside like normal DOS programs, and they rely on MS-DOS and BIOS for file I/O and other basic functions such as keyboard input, screen cursor position, etc. DJGPP programs use "DPMI" (the DOS Protected Mode Interface) to allow DOS/BIOS calls from protected mode. Therefore, any environment that can run DOS programs and provides DPMI services, will run DJGPP programs as well. Environments that are known to be compatible with DJGPP include MS-DOS, DR-DOS, NWDOS, FreeDOS, OpenDOS, Windows 3.X, 9X and NT, OS/2, and Linux DOSEmu. When DJGPP programs run on Windows 9X, they support long filenames. Programs compiled with DJGPP can access all the physical memory on your machine and support virtual memory. All this memory presents a flat address space with no segmentation (you can say goodbye to far and huge pointers and to memory models), and is only limited by the amount of virtual memory supported by the DPMI server in use. A typical DPMI server can provide at least 64MB of virtual memory (if you have enough free disk space). DJGPP is free: you don't have to pay anything to download and use it, even if you write commercial programs. DJGPP doesn't impose any restrictions on programs that you write and compile with it: you can make them commercial, shareware, freeware, or any other kind. (There are a few minor exceptions to that rule, see (un)restrictions on distribution of DJGPP apps in Application distribution.) The core of DJGPP is the MS-DOS port of the GNU C/C++ compiler, GCC, and auxiliary utilities, such as assembler, linker, librarian, Make, and a hypertext docs browser. The DJGPP C library was written specifically for DJGPP, mainly by DJ Delorie himself, with help from a small group of volunteers. DJGPP presents a set of tools which are remarkably ANSI- and Posix-compliant(1). GCC complies to ANSI/ISO C Standard; the DJGPP C library is ANSI- and Posix-compliant (however, a small number of Posix features, like the `fork' system call, are unimplemented); the C++ libraries also comply to the latest standards; and the GNU development tools used by DJGPP are all Posix-compliant. As a result, DJGPP tools provide a complete and coherent Posix layer on top of Microsoft operating systems, to the degree that even the infamous limitations of DOS and incompatibilities between DOS/Windows and Unix are almost completely concealed from users and developers. Here are some of the tasks that DJGPP is said to be good for: - learning C and C++ programming and teaching others to program in C/C++; - using Unix development tools on MS-DOS and MS-Windows; - writing games(2) and graphics programs; - setting up a common development environment for Unix and MS-DOS/MS-Windows; - writing portable DOS/Unix programs; - porting Unix programs to Microsoft operating systems.