Lesson 14: Our First GUI Program

Blog post by darkwyrm on Tue, 2010-04-13 23:47

It's about time: our first program which does more than print stuff to the Terminal! Now the real fun begins! Learning to Program With Haiku, Lesson 14.

Comments

Re: Lesson 14: Our First GUI Program

Great tutorial, thanks.

Re: Lesson 14: Our First GUI Program

Thank's again.

Re: Lesson 14: Our First GUI Program

AH, the good stuff. :)

Thanks a lot.

Re: Lesson 14: Our First GUI Program

The lesson 14 link on this-> http://www.haiku-os.org/development/learning_to_program_with_haiku
page doesn't point to the pdf.

Re: Lesson 14: Our First GUI Program

Re: Lesson 14: Our First GUI Program

I tried to compile the app from the terminal

gcc app.cpp -o app

and got loads of undefined references to BApplication::something, the last one being BApplication::~BApplication. How should I compile it? It works fine in Paladin, but it crashses on my desktop.

Re: Lesson 14: Our First GUI Program

Compiling requires the system libraries libbe.so and libroot.so. When you try to compile from within the terminal you also need to include these, so that the compiler can find the BApplication, etc. You can either type out the full path in the terminal (/boot/system/lib/libbe.so) or you can copy and paste the libraries into the same folder that the rest of your source code is in. If you choose the latter, then just type the name of the lib when compiling.

Re: Lesson 14: Our First GUI Program

HI. I installed Haiku R1 alpha 4 on one of my computer and I use Paladin 1.3 as you suggest.
In "change system library..." there isn't libsupc++.so.
When I run, it returns the following errors:

/boot/home/projects/Ciao/App.cpp: In method `App::App()':
/boot/home/projects/Ciao/App.cpp:10: parse error before character 0342
/boot/home/projects/Ciao/App.cpp:16: `frame' undeclared (first use this function)
/boot/home/projects/Ciao/App.cpp:16: (Each undeclared identifier is reported only once
/boot/home/projects/Ciao/App.cpp:16: for each function it appears in.)
/boot/home/projects/Ciao/App.cpp:16: parse error before character 0342
/boot/home/projects/Ciao/App.cpp:20: syntax error before `.'
/boot/home/projects/Ciao/App.cpp:22: parse error before character 0342
/boot/home/projects/Ciao/App.cpp:25: syntax error before `->'
/boot/home/projects/Ciao/App.cpp:27: syntax error before `->'
/boot/home/projects/Ciao/App.cpp:30: syntax error before `->'

can you help me? thanks!

Re: Lesson 14: Our First GUI Program

Hi alkasel!

You don't need to change libraries, as Alpha4 is gcc2hybrid. Only if you use gcc4, you'll need some different libraries.
I've had these "parse error before character 0342" myself, and those turned out to be some sort of invisible control characters coming from copy&pasting from the PDF. Try to type in these lines by hand and remove the copied lines. The other errors will probably disappear then, too.

Regards,
Humdinger

Re: Lesson 14: Our First GUI Program

I used to get that problem with program listings captured from copying web-pages. I wrote a program called file-filter check out:

http://haikuware.com/directory/view-details/system-files/tracker-add-ons...

I wrote a CLI version, a GUI version, and an Add-On version.

Hope that helps.

Re: Lesson 14: Our First GUI Program

Hello,

It was smooth sailing until I got to this chapter.
I am not able to compile App.cpp, whether from the terminal or Paladin. I'm getting the following error:

/boot/develop/headers/os/app/Application.h: In function `int main()':
/boot/develop/headers/os/app/Application.h:47: `thread_id BApplication::Run()' is inaccessible
/boot/home/forge/chap14/App.cpp:26: within this context

libbe.so and libroot.so are selected in Paladin.

Re: Lesson 14: Our First GUI Program

Please ignore my above post.

Re: Lesson 14: Our First GUI Program

Compiling from the prompt is as follows.

gcc -oApp -lbe App.cpp

The -lbe is essential to get rid of all those error messages, not a problem if you use Paladin.