0

code is like:

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

using namespace Graph_lib;

int main()
{
    Point t1 {100, 100};
    Simple_window win {t1, 600, 400, "Canvas"};
    win.wait_for_button();
}

Simple_window.h and Graph.h is headers Stroustrup made himself. download from www.stroustrup.com I installed fltk (mingw64/mingw-w64-x86_64-fltk 1.3.5-1) using msys in Windows10. As I tried, fltk-config doesn't work in windows10 cmd, so I'm using msys to use fltk.

error is like:

hendr@DESKTOP-DC4NCDT MSYS /d/home/prog/cpp/gui
$ fltk-config --compile First.cpp
x86_64-w64-mingw32-g++ -I/mingw64/include -mwindows -DWIN32 -DUSE_OPENGL32 -march=x86-64 -mtune=generic -O2 -pipe -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o 'First' 'First.cpp' -mwindows -pipe -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc /mingw64/lib/libfltk.a -lole32 -luuid -lcomctl32
In file included from PPP2code\GUI.h:7,
                 from PPP2code\Simple_window.h:2,
                 from First.cpp:2:
PPP2code\Graph.h:159:24: warning: narrowing conversion of 'fl_color()' from 'Fl_Color' {aka 'unsigned int'} to 'int' [-Wnarrowing]
  159 |  Color lcolor {fl_color()};
      |                ~~~~~~~~^~
In file included from First.cpp:2:
PPP2code\Simple_window.h:9:24: error: reference to 'Window' is ambiguous
    9 | struct Simple_window : Window {
      |                        ^~~~~~
In file included from PPP2code\GUI.h:6,
                 from PPP2code\Simple_window.h:2,
                 from First.cpp:2:
PPP2code\Window.h:16:7: note: candidates are: 'class Graph_lib::Window'
   16 | class Window : public Fl_Window {
      |       ^~~~~~
In file included from D:/msys64/mingw64/include/FL/x.H:30,
                 from D:/msys64/mingw64/include/FL/fl_draw.H:27,
                 from PPP2code\fltk.h:10,
                 from PPP2code\GUI.h:5,
                 from PPP2code\Simple_window.h:2,
                 from First.cpp:2:
D:/msys64/mingw64/include/FL/win32.H:30:14: note:                 'typedef struct HWND__* Window'
   30 | typedef HWND Window;
      |              ^~~~~~
In file included from First.cpp:2:
PPP2code\Simple_window.h: In constructor 'Simple_window::Simple_window(Graph_lib::Point, int, int, const string&)':
PPP2code\Simple_window.h:11:4: error: class 'Simple_window' does not have any field named 'Window'
   11 |  : Window(xy,w,h,title),
      |    ^~~~~~
PPP2code\Simple_window.h:13:34: error: no matching function for call to 'Graph_lib::Point::Point(int, int)'
   13 |    next_button(Point(x_max()-70,0), 70, 20, "Next", cb_next) { attach(next_button); }
      |                                  ^
In file included from PPP2code\GUI.h:4,
                 from PPP2code\Simple_window.h:2,
                 from First.cpp:2:
PPP2code\Point.h:9:8: note: candidate: 'Graph_lib::Point::Point()'
    9 | struct Point {
      |        ^~~~~
PPP2code\Point.h:9:8: note:   candidate expects 0 arguments, 2 provided
PPP2code\Point.h:9:8: note: candidate: 'constexpr Graph_lib::Point::Point(const Graph_lib::Point&)'
PPP2code\Point.h:9:8: note:   candidate expects 1 argument, 2 provided
PPP2code\Point.h:9:8: note: candidate: 'constexpr Graph_lib::Point::Point(Graph_lib::Point&&)'
PPP2code\Point.h:9:8: note:   candidate expects 1 argument, 2 provided
In file included from First.cpp:2:
PPP2code\Simple_window.h:13:64: error: 'attach' was not declared in this scope; did you mean 'atanh'?
   13 |    next_button(Point(x_max()-70,0), 70, 20, "Next", cb_next) { attach(next_button); }
      |                                                                ^~~~~~
      |                                                                atanh

Is this error due to Simple_window.h, Graph.h or fltk or I'm trying this in Windows10 than linux? I'm barely newby to c++ so fixing headers from book is impossible job for me.. Is anyone who tried this?

  • 3rd-party graphics libraries like FLTK are changing rapidly. It is expected that *any* code based on them gets outdated soon and stops compiling. I would not rely on *any* graphics code from any book and instead refer to online manuals for the given framework. In case of FLTK you can start [here](https://www.fltk.org/doc-1.3/basics.html). Don't waste time like [these guys](https://stackoverflow.com/questions/7134049/stroustrups-simple-window-h) trying to make old examples work, it's not worth it. – rustyx Mar 07 '21 at 16:45
  • You have several issues here, FLTK which changed a bit, OSs which changed as well and at the end compilers which changed significantly. My solution is install FLTK from your repo (for Linux, idk about Windows) and compile it by hand, using your OSs documentation. that's how I did it several years ago. –  Mar 07 '21 at 16:59

0 Answers0