tags:

views:

883

answers:

3

I'm having a lot of trouble getting FLTK to be compliant when I try to write code in Code::Blocks. I'm guessing this is because I downloaded/installed it incorrectly. I've tried to look for installation guides like

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

but I don't really know what it means. I've been obtaining my source files from here.

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

What I've tried so far is downloading the zipped folder and extracting it to my C++ folder, and then setting the IDE to search for directories in the fltk folder, but that doesn't work - I think it's a bigger problem than just looking for headers.

Can anyone with experience using FLTK point me in the right direction? Here is an example of the code used to create a simple window.

#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
}

The headers in the program can be found here if you're interested.

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

+1  A: 

Ok. You can't just unzip the darn thing into your folder. Install Cygwin, and select gcc4-g++ during the installation process (so that g++ and its dependencies are installed). Add Cygwin to your PATH (Right Click "My Computer" -> Properties -> Advanced -> Environment Variables, create an environment variable named "CYGWIN_HOME" with the value "C:\cygwin" or wherever cygwin is installed, edit the PATH environment variable and append ";%CYGWIN_HOME%\bin;%CYGWIN_HOME%\sbin;%CYGWIN_HOME%\usr\bin;%CYGWIN_HOME%\usr\sbin"). Direct Code::Blocks to use Cygwin's version of g++. Download and extract FLTK to anywhere. In that folder, run "./configure" then "make" then "sudo make install". Execute "fltk-config --cflags", and setup Code::Blocks to add those flags to the default compiler flags. Execute "fltk-config --ldflags" and direct Code::Blocks to add the output of that command to the default linker flags.

Michael Aaron Safyan
A: 

What Michael said, though you can also compile the library using Visual Studio. If you look in the fltk directory, you'll see a directory called visualc. In there is a file called fltk.dsw. Open that up in Visual Studio, build the project, and you should be good to go. If you're using Visual Studio 2005 or later, you want vc2005/fltk.sln instead.

The README file in the directory you unzipped fltk into mentions this.

Meredith L. Patterson
I decided to switch over to Visual Studio Express. Do I need to create a project to compile a file? Can I not just compile a single file?
trikker
You're missing the point here. fltk is a library that contains object code, not just a bunch of headers. In order to use it, you'll need to compile the library, include the appropriate headers in your source code, and link against the library when you compile your code.
Meredith L. Patterson
My question above didn't have anything to do with fltk, it was just about using Visual C++ in general. I now know that I have to create files in a project to compile them.
trikker
A: 

hi, I want to use code::blocks to make a fltk project; at the beginning it demand the path to the fltk folder. when I put the path, it doesn't work! the problem is that the wizard couldn't locate the include directory. I have downloded the fltk from www.fltk.org! none of the versions contains an include directory !

houssy