Link to home
Start Free TrialLog in
Avatar of Shark Boy
Shark Boy

asked on

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
Avatar of SStory
SStory
Flag of United States of America image

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
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
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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