Having Trouble Compiling First GUI Example Code in PPP2 on Chapter 12 Section 12.3

494 views
Skip to first unread message

Osman Zakir

unread,
Mar 18, 2017, 12:29:55 PM3/18/17
to PPP-public
I also had trouble building FLTK 1.3.4-1 from source using CMake, evidenced by the fact that my lib folder in the FLTK directory is empty save for the README file, but right now the main point is what the title says.  I got the headers and their accompanying .cpp files from the book's support site, but I couldn't compile the code at all because there a whole bunch of errors.  Though maybe the main reason is that I'm using Visuals Studio 2017.  I don't have VS2015 anymore since I uninstalled it after installing VS2017.  I wonder if that was a dumb move on my part, since I can't find a link on Microsoft's site to download VS2015 anymore.

If someone can give me FLTK binaries for Windows that can work under VS2017, that'd be appreciated. 

For now, I'll post my main file here to go with the attached file which is a text file with the errors and warnings on it.  I'll also attach the headers and other files later if anyone asks. 

I tried to compile it under VS' Clang/C2 compiler.  So the error and warning messages are the same as Clang's.  I also added the compiler flag "-std=c++14". 

// Osman Zakir
// 3 / 18 / 2017
// Bjarne Stroustrup: Programming: Principles and Practice Using C++ 2nd Edition
// Chapter 12 Section 12.3 First GUI Example
// 12_3_first_gui_example.cpp

#include "../../Simple_window.h"
#include "../../Graph.h"

int main()
{
 
using namespace Graph_lib;

 
Point tl{ 100, 100 };

 
Simple_window win{ tl, 600, 400, "Canvas" };

 
Graph_lib::Polygon poly;

 poly
.add(Point{ 300, 200 });
 poly
.add(Point{ 350, 100 });
 poly
.add(Point{ 400, 200 });

 poly
.set_color(Color::red);

 win
.attach(poly);

 win
.wait_for_button();
}

gui_code_compiler_output.txt

Jonathan Garcia

unread,
May 16, 2017, 6:29:55 PM5/16/17
to PPP-public
Osman,

I ran into a similar problem when trying chapter 12.3 First Example. I have finally today successfully got the example to compile.

First I compiled the fltk binaries with visual studio 2017 by building the solution file provided in fltk<your-version>/ide/VisualC2010/fltk.sln
This solution also comes with a working demo of all the 

Then I downloaded updated header files from https://github.com/GuillaumeMajstruk/StroustrupGraphicsSourceFiles and used those in place of the files provided by the books website.
FYI - I found an error in the updated headers in Graph.cpp line 57   bool intersect should be bool line_segment_intersect

Hope this helps :)

Osman Zakir

unread,
May 26, 2017, 1:33:00 PM5/26/17
to PPP-public
Eh, updated headers?  I didn't know about those.  I'm on Chapter 14 now (though I need to figure out Chapter 13 Exercise 8's draw_lines() function still) and I'm using the GUI interface code provided by the book which I managed to get to work after reading some posts on here about how to get it to work.

So is the error you noted from Graph.cpp the only I need to be wary of?  Or are there more? 
Reply all
Reply to author
Forward
0 new messages