Problem when installing FLTK on Visual Studio 2012

Jan 6, 2014 at 9:22am
My machine in Windows 7 32-bit and my compiler for C++ is Visual Studio 2012 so first I downloaded FLTK from here (http://www.stroustrup.com/Programming/FLTK/) and then I did the works as follows has wanted me:

1- Unzip the downloaded file and open the main folder, fllk-l.l.? In a Visual C++ folder (e.g., vc2005 or venet), open fltk.dsw. If asked about updating old project files, choose Yes to All.

PS: My compiler is vc2012 instead of vc2005 and there wasn't any file named fltk.dsw in vc2005 or venet folders, so I chose the fltk.sln from vcnet and installed it. There were some failing when installing but it finished finally!

2- From the Build menu, choose Build Solution. This may take a few minutes. The source code is being compiled into static link libraries so that you do not have to recompile the FLTK source code any time you make a new project. When the process has finished , close Visual Studio.

3- From the main FLTK directory open the lib folder. Copy (not just move/drag) all the .lib files except README.lib (there should be scven) into C:\Prograrn Files\Microsoft Visual Studio\Vc\lib.

4- Go back to the FLTK main directory and copy the FL folder into C:\Program Files\Microsoft Visual Studio\Vc\include.

5- Create a new project in Visual Studio with one change to the usual procedure: create a "\Vin32 project" instead of a "console application" when choosing your project type. Be sure to create an "empty project"; otherwise, some "software wizard" will add a lot of stuff to your project that you are unlikely to need or understand.

6- In Visual Studio, choose Project from the main (top) menu, and from the drop-down menu choose Properties.

7- In the Properties dialog box, in the left menu, click the Linker folder. This expands a sub-menu. In this sub-menu, click Input. In the Additional Dependencies text field on the right, enter the following text: fltkd.lib wsock32.lib comctl32.lib fltkjpegd.lib fltkimagesd.lib [The following step may be lIImecessary because il is now the default.] In the Ignore Specific Library text field, enter the following text: libcd.lib

8- [This step may be unnecessary because /MDd is now the default.] In the left menu of the same Properties window, dick C/C++ to expand a different sub-menu. Click the Code Generation sub-menu item. In the right menu, change the Runtime Library drop-down to Multi-threaded Debug DLL (/MDd). Click OK to close the Properties window.

I this step I added a new item to that newly created project (I named that project testv.cpp) and pasted this simple code for testing the FLTK:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <FL/Fl.h>
#include <FL/Fl_box.h>
#include <FL/Fl_Window.h>

//***************************

int main() 
{
  Fl_Window window(200, 200, "Window title");
  Fl_Box box(0,0,200,200, "Hey, I mean, He llo, World! ");
  window.show();
  return Fl::run();
}


After running this project (pressing F5), this error appeared!

Error 1 error LNK1104: cannot open file 'fltkd.lib wsock32.lib comctl32.lib fltkjpegd.lib fltkimagesd.lib' c:\Users\CS\documents\visual studio 2012\Projects\testv\testv\LINK

I think the problem is to do with the creating the project. After I created an empty project from Win32 Project I clicked on Add new item and chose the .cpp type. I don't know was it correct or not.

Any idea for fixing the problem?
Last edited on Jan 6, 2014 at 2:55pm
Jan 6, 2014 at 8:52pm
No idea?
Jan 6, 2014 at 10:42pm
Try an updated version of FLTK http://www.fltk.org/software.php

Building fltk-1.3.2\ide\VisualC2010\fltk.sln in VS2013 succeeded for me, should for VS2012 as well.
Jan 7, 2014 at 7:52am
The error hadn't to do with the version. And I could find the error (with help of a mate). Of course I used the 1.3.2 version. OK. After success than that code I tested the below code (page 411 of PPP):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// This is example code from Chapter 12.3 "A first example" of
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//

#include "Simple_window.h"    // get access to our window library
#include "Graph.h"            // get access to our 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 the display engine
}

//------------------------------------------------------------------------------ 


After running I got 11 errors first is: Error C1083: Cannot open include file: 'Simple_window.h': No such file or directory.

Any idea about it?
Jan 7, 2014 at 12:46pm
It's a header made by Bjarne Stroustrup you have to copy / paste

from http://www.stroustrup.com/Programming/Graphics/Simple_window.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

//
// This is a GUI support code to the chapters 12-16 of the book
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//

#ifndef SIMPLE_WINDOW_GUARD
#define SIMPLE_WINDOW_GUARD 1

#include "GUI.h"    // for Simple_window only (doesn't really belong in Window.h)
#include "Graph.h"

using namespace Graph_lib;

//------------------------------------------------------------------------------

struct Simple_window : Window {
    Simple_window(Point xy, int w, int h, const string& title );

    bool wait_for_button(); // simple event loop

private:
    Button next_button;     // the "next" button
    bool button_pushed;     // implementation detail

    static void cb_next(Address, Address); // callback for next_button
    void next();            // action to be done when next_button is pressed

};

//------------------------------------------------------------------------------

#endif // SIMPLE_WINDOW_GUARD 


[ EDIT ]
And also Graph.h
You can find all the files here : http://www.stroustrup.com/Programming/Graphics/
Last edited on Jan 7, 2014 at 12:47pm
Jan 7, 2014 at 1:35pm
Thanks. I added all the required header files into my include directory. Now I don't have any problem with the headers. The recent problem That I have with the code shown in my previous post (khoshtip (61)) is the Polygon.

When I ran the code I get 13 errors which must of them are about the Polygon identifier. For example first error is:
Error 8 error C2872: 'Polygon' : ambiguous symbol c:\users\cs\documents\visual studio 2012\projects\testv\testv\testv.cpp 19

Why my compiler doesn't know that Polygon please?

Topic archived. No new replies allowed.