2011年3月17日 星期四

[學習筆記] MinGW + Code Block + pdcurses

Step 1: 安裝Code Blocks with MinGW
下載網址:http://www.codeblocks.org/downloads

Step 2: 下載 pdcurses
網址:http://pdcurses.sourceforge.net/
至下載頁面下載檔案: pdc34dllw.zip (目前看到的最新版)

解壓縮到硬碟目錄
(我是解壓縮到 C:\pdc34dllw )

Step 3: 執行Code Blocks並設定
Settings -> Compiler and Debugger -> Link Seetings
加入檔案: C:\pdc34dllw\pdcurses.lib

Settings -> Compiler and Debugger -> Search Directories
加入目錄 C:\pdc34dllw 至 「Compiler」、「Linker」、「Resource compiler」

Step4: 建立一個新的 Console application project


程式碼測試 (test.cpp):
#include <curses.h>

int main()
{
    initscr(); /* curses模式開始 */
    printw("Hello World!!"); /*印出Hello World!!*/
    refresh(); /*將字串在螢幕上印出*/
    getch(); /*等待輸入指令*/
    endwin(); /*結束curses模式*/
    return 0;
}


Compile方法:
執行 Build->Build
把 C:\pdc34dllw\pdcurses.dll 複制到 "\debug" 或 "\release" 資料夾內
執行 Build->Run
就可以不看見測試的結果
螢幕上會出現Hello World!!的字,然後只要按下任意鍵就會結束程式(視窗)

2 則留言:

  1. 不好意思
    請問一下
    我compile過了
    執行時說"電腦遺失pdcurses.dll"
    這是為什麼呢??

    回覆刪除
    回覆
    1. 把 C:\pdc34dllw\pdcurses.dll 複制到 "\debug" 或 "\release" 資料夾內
      再試看看 ^^

      刪除