Home / api / overview / quick 
2. Quick Start
I think the better way is starting from the sdl component, which is very small.

So, let's suppose you want to write the gb.xyz component. This component:

The $ROOT variable is the directory where you uncompressed the Gambas source package.

1. Make a copy of the $ROOTsrclibsdl directory (with its contents) and name it gb.xyz .

2. Remove the sources files, but keep main.c and main.h. You will write your own main.c and main.h by modifying them.

3. Edit the $ROOTsrclibxyzMakefile.am file, and fills it as needed, as explained there.

You will get something like that:

INCLUDES = -I$(topsrcdir)srcshare @XYZINC@ EXTRADIST = .component

pkglibLTLIBRARIES = lib.gb.xyz.la

libgbxyzlaLIBADD = @XYZLIB@ libgbxyzlaLDFLAGS = @LDFLAGS@

libgbxyzlaSOURCES = main.h main.c myFirstClass.h myFirstClass.c mySecondClass.h mySecondClass.c ...

install-exec-local:         

cp ?

4. Rename the $ROOTsrclibxyzlib.gb.sdl.component file as lib.gb.xyz.component and edit it.

Be careful, this file must be UTF-8 encoded.

/component Keygb.xyz NameThe xyz component AuthorYou Alpha1

5. Edit the $ROOTsrclibMakefile.am file (located one directory up) and change the first line to add a reference to the newly created sub-directory.

SUBDIRS = debug eval db compress @QTDIR@ @NETDIR@ @SDLDIR@ @VBDIR@ @XYZDIR@

6. Edit the $ROOTconfigure.in file and add the following stuff:

...

GBCOMPONENT(   xyz,   XYZ,   /xyz component,   /gb_find(xyz.h, /usr/local /usr, include xyz*/include include/xyz*),   /gb_find(libxyz.$shlibext, /usr/local /usr, lib xyz*/lib lib/xyz*),   /$c_lib $thread_lib -lxyz,   /$thread_inc)

...

7. At the end of the $ROOTconfigure.in file, change the ACOUTPUT macro:

...

dnl ---- Create makefiles

ACOUTPUT( Makefile srcMakefile srcshareMakefile srccompMakefile srcexecMakefile srclibMakefile ... srclibcompressMakefile srclibcompresszlibMakefile srclibcompressbzlib2Makefile srclibxyzMakefile )

8. Open a terminal, go to the package root directory, and type:

$ .reconf $ .configure ... $ make ...

Everything should compile... if you didn't make a mistake of course :-)

9. To test the component, you must make three symbolic links from the .srclibxyz directory to the gambas installation directory. As root, of course:

$ su ...

  1. ln -s usrlibgambaslib.gb.xyz.component $ROOTsrclibxyzlib.gb.xyz.component
  2. ln -s usrlibgambaslib.gb.xyz.so $ROOTsrclibxyz.libslib.gb.xyz.so
  3. ln -s usrlibgambaslib.gb.xyz.la $ROOTsrclibxyzlib.gb.xyz.la

10. Now you must create the component description files by using the gbi command. You must do that each time you modify the interface of your component.

$ gbi -a ...

That's all. You should have a new component now :-)

The main file

The interpreter hooks

Writing classes

Special methods

The components description file