2009-08-03 69 views
0

當我嘗試在Code :: Blocks中編寫代碼時,我很難讓FLTK兼容。我猜這是因爲我下載/安裝不正確。我試圖尋找安裝指南像使用Code :: Blocks在Windows上構建FLTK

http://hpux.connect.org.uk/hppd/hpux/Development/Tools/fltk-1.1.9/readme.html

,但我真的不知道這意味着什麼。我從這裏獲取我的源文件。

​​

我到目前爲止已經試過被下載的壓縮文件夾並將其解壓到我的C++文件夾,然後設置IDE搜索在FLTK文件夾目錄,但不工作 - 我認爲這不僅僅是尋找標題是一個更大的問題。

任何有使用FLTK經驗的人都能指出我的方向嗎?以下是用於創建簡單窗口的代碼示例。

#include "Simple_window.h" // get access to our windows library 
#include "Graph.h"   // get access to graphics library facilities 

int main() 
{ 
    using namespace Graph_lib; // our graphics facilities are in Graph_lib 

    Point tl(100,100);   // to become top left corner of window 

    Simple_window win(tl,600,400,"Canvas"); // make a simple window 

    Polygon poly; // make a shape (a polygon) 

    poly.add(Point(300,200));  // add a point 
    poly.add(Point(350,100));  // add another point 
    poly.add(Point(400,200));  // add a third point 

    poly.set_color(Color::red); // adjust properties of poly 

    win.attach(poly);    // connect poly to the window 

    win.wait_for_button();  // give control to display engine 
} 

如果您有興趣,可以在這裏找到程序中的標題。

http://www.stroustrup.com/Programming/

回答

1

好的。你不能把文件解壓縮到文件夾中。安裝Cygwin,並在安裝過程中選擇gcc4-g ++(以便安裝g ++及其依賴項)。將Cygwin添加到PATH中(右鍵單擊「我的電腦」 - >屬性 - >高級 - >環境變量,創建一個名爲「CYGWIN_HOME」的值爲「C:\ cygwin」或安裝了cygwin的環境變量,編輯PATH環境變量和追加「;%CYGWIN_HOME%\ bin;%CYGWIN_HOME%\ sbin;%CYGWIN_HOME%\ usr \ bin;%CYGWIN_HOME%\ usr \ sbin」)。 Direct Code :: Blocks使用Cygwin的g ++版本。下載並提取FLTK到任何地方。在該文件夾中,運行「./configure」,然後「make」,然後「sudo make install」。執行「fltk-config --cflags」,並設置Code :: Blocks將這些標誌添加到默認編譯器標誌。執行「fltk-config --ldflags」並指示Code :: Blocks將該命令的輸出添加到默認鏈接器標誌。

0

邁克爾說,儘管你也可以使用Visual Studio編譯庫。如果你查看fltk目錄,你會看到一個名爲visualc的目錄。有一個文件叫做fltk.dsw。在Visual Studio中打開該項目,構建該項目,並且應該很好。如果您使用Visual Studio 2005或更高版本,則需要使用vc2005/fltk.sln

README文件在你解壓fltk的目錄裏提到了這一點。

+0

我決定切換到Visual Studio Express。我是否需要創建一個項目來編譯文件?我不能只編譯一個文件嗎? – trikker 2009-08-03 01:56:30