Code::Blocks C++ fatal error

Hi, I have a fatal error and I don't know what to do. I'm learning Code::Blocks with the Sroustrup book. Here my code:


//
// 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


//
// 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
3.png
Shark BoyAsked:
Who is Participating?
 
jkrCommented:
There's another option:

- locate the directory where "gui.h" and "graph.h" reside
- go to "Control Panel|System and Security|System|Advanced"
- click "Environment Variables" (right above the "OK/Cancel" buttons)
- select "New...", enter "INCLUDE" as the name and the directory path from the 1st point as the calue"

Then, just restart Code::Blocks and everything should be fine.
0
 
SStoryCommented:
If you are using Visual C++ then
To locate includable source files, the preprocessor first searches the directories that are specified by the /I compiler option. If the /I option is not present or fails, the preprocessor uses the INCLUDE environment variable to find any include files within angle brackets. The INCLUDE environment variable and /I compiler option can contain multiple paths, separated by semicolons (;). If more than one directory appears as part of the /I option or within the INCLUDE environment variable, the preprocessor searches them in the order in which they appear.

For example, the command

https://msdn.microsoft.com/en-us/library/36k2cdd4.aspx
0
 
ZoppoCommented:
Hi Shark Boy,

the error message is pretty clear, it tells you a file GUI.h which is included in you code (with #include) couldn't be found by the compiler.

If this is a sample from the mentioned book you should look if there are preceeding instructions, possibly you can find how to get the missing files. If you already have the needed file(s) you'll have to either move them into your project's folder or add a include directory in your project's configuration in order to make it possible the compiler finds the file.

Hope that helps,

ZOPPO
0
 
sarabandeCommented:
This is a GUI support code to the chapters 12-16 of the book

Open in new window

i would assume that gui.h and graph.h were added in an earlier chapter of the tutorial book.

if you just started with the book it makes less sense to start somewhere in the middle but from beginning to avoiding basic issues like the one you reported.

Sara
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.