Install FLTK on VS 2013

Hello all,

Is there a correct way of installing FLTK (say. 1.3.2) on vs 2013 and get it ran below code successfully?

1
2
3
4
5
6
7
8
9
10
#include <Simple_window.h>

int main()
{
	Simple_window win(Point(100, 100), 1000, 600, "test");
	Circle c(Point(200, 200), 50);
	win.attach(c);
	win.wait_for_button();
}


I got this error: Error 16 error C2440: 'return' : cannot convert from 'std::ifstream' to 'bool' c:\program files\microsoft visual studio 12.0\vc\include\graph.cpp 371 1 Win32Project1
It looks that there is an error in graph.cpp which prevents this code to work on compilers which strictly adheres to standard.

Any chance you can post relevant line from graph.cpp?
The problem has to do with this
1
2
3
4
5
6
bool can_open(const string& s)
            // check if a file named s exists and can be opened for reading
{
	ifstream ff(s.c_str());
	return ff;
}
part of the graph.cpp (http://www.stroustrup.com/Programming/PPP2code/Graph.cpp ). It's in lower parts of the file.

But when I install FLTK on vs 2012 I have no problem with the code (circle ....)!
Basically you need to change line 5 to return static_cast<bool>(ff);

It looks like an error in original code. I am still not sure if it is that way, but it looks like returning a value implicitely convert it to return type (as opposed to explicitely)
As operator bool is explicit it cannot be used in implicit conversions.
This way I get linking errors (5 ones), one of them:

Error 10 error LNK2001: unresolved external symbol "public: virtual void __thiscall Fl_Image::color_average(enum Fl_Color,float)" (?color_average@Fl_Image@@UAEXW4Fl_Color@@M@Z) C:\Users\CS\documents\visual studio 2013\Projects\Win32Project1\Win32Project1\fltkimagesd.lib(Fl_GIF_Image.obj) Win32Project1

I had that FLTK with vs 2012 but hadn't such a problem. My vs 2013 is update 3.
Last edited on
Topic archived. No new replies allowed.