使用Code :: Blocks在Windows上构建FLTK

时间:2009-08-03 00:11:09

标签: c++ user-interface

当我尝试在Code :: Blocks中编写代码时,我在使FLTK符合要求方面遇到了很多麻烦。我猜这是因为我下载/安装不正确。我试图寻找像

这样的安装指南

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

但我真的不知道这意味着什么。我一直在这里获取我的源文件。

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

我到目前为止尝试的是下载压缩文件夹并将其解压缩到我的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/

2 个答案:

答案 0 :(得分:1)

确定。你不能只是将darn东西解压缩到你的文件夹中。安装Cygwin,并在安装过程中选择gcc4-g ++(以便安装g ++及其依赖项)。将Cygwin添加到PATH(右键单击“我的电脑” - > gt;属性 - >高级 - >环境变量,创建一个名为“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将该命令的输出添加到默认链接器标志。

答案 1 :(得分:0)

迈克尔说,虽然您也可以使用Visual Studio编译库。如果你查看fltk目录,你会看到一个名为visualc的目录。在有一个名为fltk.dsw的文件中。在Visual Studio中打开它,构建项目,你应该很高兴。如果您使用的是Visual Studio 2005或更高版本,则需要使用vc2005/fltk.sln

解压缩目录中的README文件提到了这一点。