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: * Depends on no other component. * Needs the libxyz.so library and the xyz.h include file. * Needs multi-threading.

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

  1. Make a copy of the $ROOT/src/lib/sdl directory (with its contents) and name

it gb.xyz .

  1. Remove the sources files, but keep main.c and main.h. You will write your

own main.c and main.h by modifying them.

  1. Edit the $ROOT/src/lib/xyz/Makefile.am file, and fills it as needed, as

explained there.

You will get something like that:

INCLUDES = -I$(top_srcdir)/src/share @XYZ_INC@
EXTRA_DIST = *.component

pkglib_LTLIBRARIES = lib.gb.xyz.la

lib_gb_xyz_la_LIBADD = @XYZ_LIB@
lib_gb_xyz_la_LDFLAGS = @LD_FLAGS@

lib_gb_xyz_la_SOURCES =  main.h main.c  myFirstClass.h myFirstClass.c  mySecondClass.h mySecondClass.c  ...

install-exec-local:
        @cp -f *.component $(DESTDIR)$(pkglibdir)

  1. Rename the $ROOT/src/lib/xyz/lib.gb.sdl.component file as

lib.gb.xyz.component and edit it.

Be careful, this file must be UTF8 encoded.

[Component]
Key=gb.xyz
Name=The xyz component
Author=You
Alpha=1

  1. Edit the $ROOT/src/lib/Makefile.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 @QT_DIR@ @NET_DIR@ @SDL_DIR@ @VB_DIR@ @XYZ_DIR@

  1. Edit the $ROOT/configure.in file and add the following stuff:

    ...
    
    
    GB_COMPONENT(
     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])
    
    
    ...

  2. At the end of the $ROOT/configure.in file, change the AC_OUTPUT macro:

    ...
    
    
    dnl ---- Create makefiles
    
    
    AC_OUTPUT( Makefile src/Makefile src/share/Makefile src/comp/Makefile src/exec/Makefile src/lib/Makefile ... src/lib/compress/Makefile src/lib/compress/zlib/Makefile src/lib/compress/bzlib2/Makefile src/lib/xyz/Makefile )

  3. 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 :-)

  1. To test the component, you must make three symbolic links from

the ./src/lib/xyz directory to the Gambas installation directory. As root, of course:

$ su
...
# ln -s /usr/lib/gambas/lib.gb.xyz.component $ROOT/src/lib/xyz/lib.gb.xyz.component
# ln -s /usr/lib/gambas/lib.gb.xyz.so $ROOT/src/lib/xyz/.libs/lib.gb.xyz.so
# ln -s /usr/lib/gambas/lib.gb.xyz.la $ROOT/src/lib/xyz/lib.gb.xyz.la

  1. . 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