<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../style.css">
<title>
Gambas Documentation - 2. Quick Start
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../../help+en"><img class="flag" alt="Home" border="0" src="../../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../overview+en">Up</a>&nbsp;
<a href="intro+en">Previous</a>&nbsp;
<a href="../../cat+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
2. Quick Start
</h1>
I think the better way is starting from the sdl component, which is very
small.
<p>
So, let's suppose you want to write the <a href="../../comp/gb/gb+en">gb</a>.xyz component. This component:
<ul>
<li>Depends on no other component.
<li>Needs the libxyz.so library and the xyz.h include file.
<li>Needs multi-threading.
<p>
</ul>

The $ROOT variable is the directory where you uncompressed the <a href="../../def/gambas+en">Gambas</a> source package.
<p>
1. Make a copy of the $ROOT<i>src</i>lib<i>sdl directory (with its contents) and name
it <a href="../../comp/gb/gb+en">gb</a>.xyz .
<p>
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.
<p>
3. Edit the $ROOT</i>src<i>lib</i>xyz<i>Makefile.am file, and fills it as needed, as
explained there.
<p>
You will get something like that:
<p>
INCLUDES = -I$(top<u>srcdir)</i>src<i>share @XYZ</u>INC@
EXTRA<u>DIST = <b>.component
<p>
pkglib</u>LTLIBRARIES = lib.<a href="../../comp/gb/gb+en">gb</a>.xyz.la
<p>
lib<u><a href="../../comp/gb/gb+en">gb</a></u>xyz<u>la</u>LIBADD = @XYZ<u>LIB@
lib</u><a href="../../comp/gb/gb+en">gb</a><u>xyz</u>la<u>LDFLAGS = @LD</u>FLAGS@
<p>
lib<u><a href="../../comp/gb/gb+en">gb</a></u>xyz<u>la</u>SOURCES =  main.h main.c  myFirstClass.h myFirstClass.c  mySecondClass.h mySecondClass.c  ...
<p>
install-exec-local:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@cp
<p>

4. Rename the $ROOT</i>src<i>lib</i>xyz<i>lib.<a href="../../comp/gb/gb+en">gb</a>.sdl.component file as
lib.<a href="../../comp/gb/gb+en">gb</a>.xyz.component and edit it.
<p>
Be careful, this file must be <a href="../../def/utf8+en">UTF-8</a> encoded.
<p>

<i>/component</i>
Key<tt><a href="../../comp/gb/gb+en">gb</a>.xyz
Name</tt>The xyz component
Author<tt>You
Alpha</tt>1
<p>

5. Edit the $ROOT</i>src<i>lib</i>Makefile.am file (located one directory up) and change the first
line to add a reference to the newly created sub-directory.
<p>

SUBDIRS = debug eval db compress @QT<u>DIR@ @NET</u>DIR@ @SDL<u>DIR@ @VB</u>DIR@ @XYZ<u>DIR@
<p>

6. Edit the $ROOT<i>configure.in file and add the following stuff:
<p>

...
<p>
GB</u>COMPONENT(
&nbsp;&nbsp;xyz,
&nbsp;&nbsp;XYZ,
&nbsp;&nbsp;<i>/xyz component</i>,
&nbsp;&nbsp;<i>/gb_find(xyz.h, /usr/local /usr, include xyz*/include include/xyz*)</i>,
&nbsp;&nbsp;<i>/gb_find(libxyz.$shlibext, /usr/local /usr, lib xyz*/lib lib/xyz*)</i>,
&nbsp;&nbsp;<i>/$c_lib $thread_lib -lxyz</i>,
&nbsp;&nbsp;<i>/$thread_inc</i>)
<p>
...
<p>

7. At the end of the $ROOT</i>configure.in file, change the AC<u>OUTPUT macro:
<p>

...
<p>
dnl ---- Create makefiles
<p>
AC</u>OUTPUT( Makefile src<i>Makefile src</i>share<i>Makefile src</i>comp<i>Makefile src</i>exec<i>Makefile src</i>lib<i>Makefile ...
src</i>lib<i>compress</i>Makefile src<i>lib</i>compress<i>zlib</i>Makefile src<i>lib</i>compress<i>bzlib2</i>Makefile src<i>lib</i>xyz<i>Makefile )
<p>

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

$ .</i>reconf
$ .<i>configure
...
$ make
...
<p>

Everything should compile... if you didn't make a mistake of course :-)
<p>
9. To test the component, you must make three symbolic links from
the .</i>src<i>lib</i>xyz directory to the gambas installation directory. As root, of
course:
<p>

$ su
...
<ol>
<li>ln -s <i>usr</i>lib<i>gambas</i>lib.<a href="../../comp/gb/gb+en">gb</a>.xyz.component $ROOT<i>src</i>lib<i>xyz</i>lib.<a href="../../comp/gb/gb+en">gb</a>.xyz.component
<li>ln -s <i>usr</i>lib<i>gambas</i>lib.<a href="../../comp/gb/gb+en">gb</a>.xyz.so $ROOT<i>src</i>lib<i>xyz</i>.libs<i>lib.<a href="../../comp/gb/gb+en">gb</a>.xyz.so
<li>ln -s </i>usr<i>lib</i>gambas<i>lib.<a href="../../comp/gb/gb+en">gb</a>.xyz.la $ROOT</i>src<i>lib</i>xyz<i>lib.<a href="../../comp/gb/gb+en">gb</a>.xyz.la
<p>

</ol>

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

$ gbi -a
...
<p>

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

<h2>The main file</h2>
<h2>The interpreter hooks</h2>
<h2>Writing classes</h2>
<h2>Special methods</h2>
<h2>The components description file</h2>

</div>
</body>
</html>

