Newbie Question

I know that this section is going to be closed but the question is pretty basic and this is more or less the first time I’m coding applications in C++ so I thought it’s better I ask here.

I’m running Haiku under VMWare and I tried to compile the first example from “Programming the Be Operating System”:

#include <Window.h> #include <Application.h> class SimpleWindow: public BWindow { public: SimpleWindow( BRect frame ); virtual bool QuitRequested(); };

SimpleWindow::SimpleWindow( BRect frame )
: BWindow( frame, “A Simple Window”, B_TITLED_WINDOW, B_NOT_RESIZABLE ) {

bool SimpleWindow::QuitRequested() {
be_app->PostMessage( B_QUIT_REQUESTED );
return true;

class SimpleApplication: public BApplication {

: BApplication( “application/x-vnd.dps-simpleapp” ) {
SimpleWindow *aWindow;
BRect aRect;
aRect.Set( 20, 20, 200, 60 );
aWindow = new SimpleWindow( aRect );

main() {
SimpleApplication myApplication;
return 0;

When I compiled it under g++, it showed error messages about undefined references. Can anyone tell me what went wrong? Am I to add compiler flags or so?

EDIT: I copy-pasted the code wrongly so fixed it…

You need to add the library reference to Be:

g++ -lbe hello.cpp

Ohh okay, thanks :slight_smile: