

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.amigaos.net/w/index.php?action=history&amp;feed=atom&amp;title=How_to_create_an_AmigaOS_4_library</id>
	<title>How to create an AmigaOS 4 library - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.amigaos.net/w/index.php?action=history&amp;feed=atom&amp;title=How_to_create_an_AmigaOS_4_library"/>
	<link rel="alternate" type="text/html" href="https://wiki.amigaos.net/w/index.php?title=How_to_create_an_AmigaOS_4_library&amp;action=history"/>
	<updated>2026-04-27T13:03:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.amigaos.net/w/index.php?title=How_to_create_an_AmigaOS_4_library&amp;diff=8585&amp;oldid=prev</id>
		<title>Steven Solie at 19:26, 29 August 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.amigaos.net/w/index.php?title=How_to_create_an_AmigaOS_4_library&amp;diff=8585&amp;oldid=prev"/>
		<updated>2016-08-29T19:26:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:26, 29 August 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;How to create an OS4 library&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This simple tutorial is based on the creation of my first library.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This simple tutorial is based on the creation of my first library.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Big thanks to Alexandre Balaban, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;TonyW&lt;/del&gt; and Andy Broad&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; Blues&lt;/del&gt; for their &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;advices&lt;/del&gt; and explanations.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Big thanks to Alexandre Balaban, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Tony Wyatt&lt;/ins&gt; and Andy Broad for their &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;advice&lt;/ins&gt; and explanations.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Steven Solie</name></author>
	</entry>
	<entry>
		<id>https://wiki.amigaos.net/w/index.php?title=How_to_create_an_AmigaOS_4_library&amp;diff=8583&amp;oldid=prev</id>
		<title>Steven Solie: Steven Solie moved page How to create an OS4 library to How to create an AmigaOS 4 library without leaving a redirect</title>
		<link rel="alternate" type="text/html" href="https://wiki.amigaos.net/w/index.php?title=How_to_create_an_AmigaOS_4_library&amp;diff=8583&amp;oldid=prev"/>
		<updated>2016-08-29T19:25:45Z</updated>

		<summary type="html">&lt;p&gt;Steven Solie moved page &lt;a href=&quot;/w/index.php?title=How_to_create_an_OS4_library&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;How to create an OS4 library (page does not exist)&quot;&gt;How to create an OS4 library&lt;/a&gt; to &lt;a href=&quot;/wiki/How_to_create_an_AmigaOS_4_library&quot; title=&quot;How to create an AmigaOS 4 library&quot;&gt;How to create an AmigaOS 4 library&lt;/a&gt; without leaving a redirect&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:25, 29 August 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Steven Solie</name></author>
	</entry>
	<entry>
		<id>https://wiki.amigaos.net/w/index.php?title=How_to_create_an_AmigaOS_4_library&amp;diff=8542&amp;oldid=prev</id>
		<title>Ölrick Lefebvre: Sample tutor on how to create an OS4 library from scratch</title>
		<link rel="alternate" type="text/html" href="https://wiki.amigaos.net/w/index.php?title=How_to_create_an_AmigaOS_4_library&amp;diff=8542&amp;oldid=prev"/>
		<updated>2016-04-21T21:05:31Z</updated>

		<summary type="html">&lt;p&gt;Sample tutor on how to create an OS4 library from scratch&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;How to create an OS4 library&lt;br /&gt;
&lt;br /&gt;
This simple tutorial is based on the creation of my first library.&lt;br /&gt;
&lt;br /&gt;
Big thanks to Alexandre Balaban, TonyW and Andy Broad Blues for their advices and explanations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Create a descriptive xml file =&lt;br /&gt;
To generate the skeleton of the library we first need to create an xml file describing it.&lt;br /&gt;
You may have a look in SDK:Include/interfaces to get inspiration.&lt;br /&gt;
&lt;br /&gt;
== The header ==&lt;br /&gt;
At the beginning you describe the type of document.&lt;br /&gt;
For my sample I got inspired by one generated by fdtrans&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;iso-8859-1&amp;quot;?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE library SYSTEM &amp;quot;library.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The library tag ==&lt;br /&gt;
The all library description is contained in the library tag.&lt;br /&gt;
First you need to enter the name of the library, the name of its base structure and the name of the library file&lt;br /&gt;
 &amp;lt;library name=&amp;quot;sample&amp;quot; basename=&amp;quot;SampleBase&amp;quot; openname=&amp;quot;sample.library&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The include tags ===&lt;br /&gt;
You use these tags to specify the include files required for the declaration of your methods signature.&lt;br /&gt;
If your methods use custom types, you should add your own new include&lt;br /&gt;
 &amp;lt;include&amp;gt;exec/types.h&amp;lt;/include&amp;gt;&lt;br /&gt;
 &amp;lt;include&amp;gt;test/sample.h&amp;lt;/include&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 In that case, don&amp;#039;t forget to place your include in SDK:local/common/include&lt;br /&gt;
&lt;br /&gt;
=== The interface tag ===&lt;br /&gt;
This tag defines an interface of your library. You should at least declare the &amp;quot;main&amp;quot; interface.&lt;br /&gt;
 &amp;lt;interface name=&amp;quot;main&amp;quot; version=&amp;quot;1.0&amp;quot; struct=&amp;quot;SampleIFace&amp;quot; prefix=&amp;quot;_sample_&amp;quot; asmprefix=&amp;quot;ISample&amp;quot; global=&amp;quot;ISample&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
==== Interface methods ====&lt;br /&gt;
In the interface section you add a method tag for each method of your library you want to publish.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: you must provide at least Obtain, Release, Expunge and Clone&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Obtain&amp;quot; result=&amp;quot;uint32&amp;quot;/&amp;gt;&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Release&amp;quot; result=&amp;quot;uint32&amp;quot;/&amp;gt;&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Expunge&amp;quot; result=&amp;quot;void&amp;quot; status=&amp;quot;unimplemented&amp;quot;/&amp;gt;&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Clone&amp;quot; result=&amp;quot;struct SampleIFace *&amp;quot;/&amp;gt;&lt;br /&gt;
===== method properties =====&lt;br /&gt;
* name: the name of the method to publish&lt;br /&gt;
* result: the data type returne by your method&lt;br /&gt;
* status: allows you to specify that a method is not implemented&lt;br /&gt;
&lt;br /&gt;
====== arg tags ======&lt;br /&gt;
Each argument of a method must be declared with an arg tag. You specify the name and the type properties&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Addition&amp;quot; result=&amp;quot;myInt&amp;quot;&amp;gt;&lt;br /&gt;
 			&amp;lt;arg name=&amp;quot;value1&amp;quot; type=&amp;quot;myInt&amp;quot;/&amp;gt;&lt;br /&gt;
 			&amp;lt;arg name=&amp;quot;value2&amp;quot; type=&amp;quot;myInt&amp;quot;/&amp;gt;&lt;br /&gt;
 		&amp;lt;/method&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once you&amp;#039;re finished with the description your file should look like this:&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;iso-8859-1&amp;quot;?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE library SYSTEM &amp;quot;library.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;library name=&amp;quot;sample&amp;quot; basename=&amp;quot;SampleBase&amp;quot; openname=&amp;quot;sample.library&amp;quot;&amp;gt;&lt;br /&gt;
 	&amp;lt;include&amp;gt;exec/types.h&amp;lt;/include&amp;gt;&lt;br /&gt;
 	&amp;lt;include&amp;gt;test/sample.h&amp;lt;/include&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;lt;interface name=&amp;quot;main&amp;quot; version=&amp;quot;1.0&amp;quot; struct=&amp;quot;SampleIFace&amp;quot; prefix=&amp;quot;_sample_&amp;quot; asmprefix=&amp;quot;ISample&amp;quot; global=&amp;quot;ISample&amp;quot;&amp;gt;&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Obtain&amp;quot; result=&amp;quot;uint32&amp;quot;/&amp;gt;&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Release&amp;quot; result=&amp;quot;uint32&amp;quot;/&amp;gt;&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Expunge&amp;quot; result=&amp;quot;void&amp;quot; status=&amp;quot;unimplemented&amp;quot;/&amp;gt;&lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Clone&amp;quot; result=&amp;quot;struct SampleIFace *&amp;quot;/&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 		&amp;lt;method name=&amp;quot;Addition&amp;quot; result=&amp;quot;myInt&amp;quot;&amp;gt;&lt;br /&gt;
 			&amp;lt;arg name=&amp;quot;value1&amp;quot; type=&amp;quot;myInt&amp;quot;/&amp;gt;&lt;br /&gt;
 			&amp;lt;arg name=&amp;quot;value2&amp;quot; type=&amp;quot;myInt&amp;quot;/&amp;gt;&lt;br /&gt;
 		&amp;lt;/method&amp;gt;&lt;br /&gt;
 	&amp;lt;/interface&amp;gt;&lt;br /&gt;
 &amp;lt;/library&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Generate the skeleton with IDLTool =&lt;br /&gt;
Open a shell in the drawer where your XML file resides and launch IDLTool so that it generates all you need&lt;br /&gt;
 idltool -a sample.xml &lt;br /&gt;
&lt;br /&gt;
== copy the includes at the right place ==&lt;br /&gt;
Now you have an include drawer which you&amp;#039;ll can put in SDK:local/common/include&lt;br /&gt;
Note: you may delay this and use the local includes while debugging your library.&lt;br /&gt;
 &amp;gt; copy include/#? SDK:local/common/include all&lt;br /&gt;
        proto (Rép.)&lt;br /&gt;
           sample.h..copié.&lt;br /&gt;
        inline4 (Rép.)&lt;br /&gt;
           sample.h..copié.&lt;br /&gt;
        interfaces (Rép.)&lt;br /&gt;
           sample.i..copié.&lt;br /&gt;
           sample.h..copié.&lt;br /&gt;
&lt;br /&gt;
If you have an include required for the signature of your methods, you can add it too.&lt;br /&gt;
 #ifndef TEST_SAMPLE_H&lt;br /&gt;
 #define TEST_SAMPLE_H&lt;br /&gt;
 &lt;br /&gt;
 typedef int myInt; &lt;br /&gt;
 &lt;br /&gt;
 #endif // TEST_SAMPLE_H&lt;br /&gt;
&lt;br /&gt;
 &amp;gt; makedir SDK:local/common/include/test&lt;br /&gt;
 &amp;gt; copy test/#? SDK:local/common/include/test&lt;br /&gt;
   sample.h..copié.&lt;br /&gt;
&lt;br /&gt;
== add the revision info ==&lt;br /&gt;
Go into the &amp;lt;library&amp;gt;_files drawer, sample_files in my example.&lt;br /&gt;
Now use bumprev to generate revision files.&lt;br /&gt;
 &amp;gt; bumprev 1.1 sample.library&lt;br /&gt;
 bumprev: Creating new file &amp;quot;sample.library_rev.rev&amp;quot;.&lt;br /&gt;
 bumprev: Bumped &amp;quot;sample.library&amp;quot; to version 1.1.&lt;br /&gt;
&lt;br /&gt;
bumprev doesn&amp;#039;t accept &amp;#039;0&amp;#039; values, but you may modify the *_rev file afterward. &lt;br /&gt;
&lt;br /&gt;
== tune init.c ==&lt;br /&gt;
IDLTool has generated source files in the &amp;lt;library&amp;gt;_files drawer.&lt;br /&gt;
First you have a init.c file and a drawer for each interface with a source file for each method declared in your xml file, except the methods tagged as &amp;#039;unimplemented&amp;#039;.&lt;br /&gt;
Your first task is to edit init.c and define your library&amp;#039;s base structure.&lt;br /&gt;
You will find a struct Library definition, rename it and enhanced it with private data if needed&lt;br /&gt;
&lt;br /&gt;
 struct Library&lt;br /&gt;
 {&lt;br /&gt;
     struct Library libNode;&lt;br /&gt;
     BPTR segList;&lt;br /&gt;
     /* If you need more data fields, add them here */&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
 struct SampleBase&lt;br /&gt;
 {&lt;br /&gt;
     struct Library libNode;&lt;br /&gt;
     BPTR segList;&lt;br /&gt;
     /* If you need more data fields, add them here */&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you enhanced it, it&amp;#039;s interesting to move it in a new header so that you can declare it in other source files.&lt;br /&gt;
In that case, don&amp;#039;t forget to add the include directive in init.c.&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;exec/exec.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;proto/exec.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;dos/dos.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;exec/types.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;test/sample.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;proto/sample.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdarg.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;samplebase.h&lt;br /&gt;
&lt;br /&gt;
samplebase.h&lt;br /&gt;
 #ifndef SAMPLEBASE_H&lt;br /&gt;
 #define SAMPLEBASE_H&lt;br /&gt;
 &lt;br /&gt;
 struct SampleBase&lt;br /&gt;
 {&lt;br /&gt;
     struct Library libNode;&lt;br /&gt;
     BPTR segList;&lt;br /&gt;
     /* If you need more data fields, add them here */&lt;br /&gt;
     struct Library *UtilityBase;&lt;br /&gt;
     struct UtilityIFace *IUtility;&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 #endif // SAMPLEBASE_H&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you must edit init.c to replace the (struct Library *) casts to your library type, (struct SampleBase *) in my case.&lt;br /&gt;
To help you find the needed places, just use make:&lt;br /&gt;
 &amp;gt; make&lt;br /&gt;
 gcc  -Wall -O3    -c -o init.o init.c&lt;br /&gt;
 init.c: In function &amp;#039;libOpen&amp;#039;:&lt;br /&gt;
 init.c:66: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c: In function &amp;#039;libExpunge&amp;#039;:&lt;br /&gt;
 init.c:94: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c:96: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;segList&amp;#039;&lt;br /&gt;
 init.c:105: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c: In function &amp;#039;libInit&amp;#039;:&lt;br /&gt;
 init.c:116: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c:117: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c:118: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c:119: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c:120: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c:121: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c:122: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;libNode&amp;#039;&lt;br /&gt;
 init.c:124: error: &amp;#039;struct Library&amp;#039; has no member named &amp;#039;segList&amp;#039;&lt;br /&gt;
 make: *** [init.o] Error 1&lt;br /&gt;
&lt;br /&gt;
Now you have the functions which use a libBase variable typed as a (struct Library *) instead of your own base, just correct the declarations and check with make.&lt;br /&gt;
&lt;br /&gt;
 &amp;gt; make&lt;br /&gt;
 gcc  -Wall -O3    -c -o init.o init.c&lt;br /&gt;
 gcc   -nostartfiles -o sample.library main/Obtain.o main/Release.o main/Clone.o main/Addition.o  init.o &lt;br /&gt;
&lt;br /&gt;
Once make succeeds, you get a brand new library&lt;br /&gt;
 &amp;gt; list sample.library &lt;br /&gt;
 sample.library                 6510 ----rwed Aujourd&amp;#039;hui 18:13:21&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= get the interfaces you need =&lt;br /&gt;
&lt;br /&gt;
Now that your library skeleton is validated, you have to implement your methods, but you may need acces to other libraries interfaces for it.&lt;br /&gt;
When you compile a regular program, the startup code adds global variables for some libraries (i.e. IExec), but in the case of a library, you don&amp;#039;t have these, so it&amp;#039;s up to you to do it.&lt;br /&gt;
&lt;br /&gt;
Except for Newlib, it&amp;#039;s a good practice to store your opened libraries and interfaces in you libbase by extended it.&lt;br /&gt;
On the other hand, using global references allows your code to look like regular code.&lt;br /&gt;
&lt;br /&gt;
== IExec ==&lt;br /&gt;
In libInit() you get a (struct Interface *) which you can keep for your library use. No need to call Obtain() on it, as Exec isn&amp;#039;t going away.&lt;br /&gt;
You may copy it to a global variable or to your libbase.&lt;br /&gt;
&lt;br /&gt;
=== global IExec ===&lt;br /&gt;
At the beginning of init.c add a global definition:&lt;br /&gt;
 struct ExecIFace *IExec = NULL;&lt;br /&gt;
In libInit(), comment out the &amp;quot;struct ExecIFace *IExec UNUSED&amp;quot; line and copy the exec argument to your variable&lt;br /&gt;
 IExec = (struct ExecIFace *)exec;&lt;br /&gt;
To access it from your sources, just include proto/exec.h as it contains a declaration for such a global interface.&lt;br /&gt;
In your code you can use method calls like&lt;br /&gt;
 IExec-&amp;gt;OpenLibrary()&lt;br /&gt;
&lt;br /&gt;
=== IExec libbase property ===&lt;br /&gt;
Extend your libbase structure to add a property to it&lt;br /&gt;
 #ifndef SAMPLEBASE_H&lt;br /&gt;
 #define SAMPLEBASE_H&lt;br /&gt;
 &lt;br /&gt;
 struct SampleBase&lt;br /&gt;
 {&lt;br /&gt;
     struct Library libNode;&lt;br /&gt;
     BPTR segList;&lt;br /&gt;
     /* If you need more data fields, add them here */&lt;br /&gt;
     struct ExecIFace *IExec;&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 #endif // SAMPLEBASE_H&lt;br /&gt;
In libInit(), copy the exec argument to your variable&lt;br /&gt;
 libBase-&amp;gt;IExec = (struct ExecIFace *)exec;&lt;br /&gt;
To access it from your sources, just include your &amp;quot;samplebase.h&amp;quot;.&lt;br /&gt;
In your code you can get the interface from the libBase through the interface pointer of your library passed to your methods&lt;br /&gt;
 struct SampleIFace * _sample_Clone(struct SampleIFace *Self)&lt;br /&gt;
 {&lt;br /&gt;
 ...&lt;br /&gt;
     ((struct SampleBase *)(Self-&amp;gt;Data.LibBase))-&amp;gt;IExec-&amp;gt;AllocVecTags()&lt;br /&gt;
&lt;br /&gt;
== INewlib ==&lt;br /&gt;
If you use functions from libc and compile with newlib (default), the compiler will complain about an undefined INewlib.&lt;br /&gt;
That&amp;#039;s because your library does not have the startup code which opens newlib.library and gets an interface from it.&lt;br /&gt;
The solution is almost the same as for a global IExec.&lt;br /&gt;
At the beginning of init.c add global definitions:&lt;br /&gt;
 struct Library *NewlibBase = NULL;&lt;br /&gt;
 struct Interface *INewlib = NULL;&lt;br /&gt;
In libInit(), open the library and get a &amp;quot;main&amp;quot; interface where the skeleton says it&lt;br /&gt;
 /* Add additional init code here if you need it. */&lt;br /&gt;
 NewlibBase = IExec-&amp;gt;OpenLibrary(&amp;quot;newlib.library&amp;quot;, 53);&lt;br /&gt;
 if(!NewlibBase)&lt;br /&gt;
 {&lt;br /&gt;
     CleanLibContext(&amp;quot;Can&amp;#039;t open V53 newlib.library&amp;quot;);&lt;br /&gt;
     return NULL;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 INewlib = (struct Interface *)IExec-&amp;gt;GetInterface(NewlibBase, &amp;quot;main&amp;quot;, 1, NULL);&lt;br /&gt;
 if(!INewlib)&lt;br /&gt;
 {&lt;br /&gt;
     CleanLibContext(&amp;quot;Can&amp;#039;t get newlib main interface&amp;quot;);&lt;br /&gt;
     return NULL;&lt;br /&gt;
 }&lt;br /&gt;
CleanLibContext() may look like this:&lt;br /&gt;
 void CleanLibContext(const char *msg)&lt;br /&gt;
 {&lt;br /&gt;
     IExec-&amp;gt;DebugPrintF(&amp;quot;%s\n&amp;quot;, msg);&lt;br /&gt;
     if(NewlibBase)&lt;br /&gt;
     {&lt;br /&gt;
         if(INewlib)&lt;br /&gt;
         {&lt;br /&gt;
             IExec-&amp;gt;DropInterface(INewlib);&lt;br /&gt;
             INewlib = NULL;&lt;br /&gt;
         }&lt;br /&gt;
         IExec-&amp;gt;CloseLibrary(NewlibBase);&lt;br /&gt;
         NewlibBase = NULL;&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
Now you can enjoy libc functions.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NB: Do not make a call to a libc function before getting your interface, it&amp;#039;s bad !&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In libExpunge() you must clean up your resources after the dedicated comment:&lt;br /&gt;
 /* Undo what the init code did */&lt;br /&gt;
  CleanLibContext(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== other libraries ==&lt;br /&gt;
Now you should have a pretty clear idea of how to do it for whatever library.&lt;br /&gt;
* define pointers for the library and the interface,&lt;br /&gt;
* open the library and get the interface in libInit()&lt;br /&gt;
** if you get an error while opening the library or getting the interface, clean up your resources and return NULL in libInit()&lt;br /&gt;
* in libExpunge() close everything opened&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Implement your library&amp;#039;s methods =&lt;br /&gt;
IDLTool has generated a source file for each of the declared methods.&lt;br /&gt;
You just fill them with your code.&amp;lt;br&amp;gt;&lt;br /&gt;
This is a profundly trivial example&lt;br /&gt;
 myInt _sample_Addition(struct SampleIFace *Self,&lt;br /&gt;
        myInt value1,&lt;br /&gt;
        myInt value2)&lt;br /&gt;
 {&lt;br /&gt;
     return (value1 + value2);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Test your library =&lt;br /&gt;
Once your library is built, it&amp;#039;s time to check each method with a simple test program.&lt;br /&gt;
 #include &amp;lt;proto/exec.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;proto/sample.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int main(int argc, char *argv[])&lt;br /&gt;
 {&lt;br /&gt;
     myInt val1, val2, res;&lt;br /&gt;
     &lt;br /&gt;
     struct Library *SampleBase = NULL;&lt;br /&gt;
     struct SampleIFace *ISample = NULL;&lt;br /&gt;
     &lt;br /&gt;
     SampleBase = (struct Library *)IExec-&amp;gt;OpenLibrary(&amp;quot;sample.library&amp;quot;, 0);&lt;br /&gt;
     if(!SampleBase)&lt;br /&gt;
         return -1;&lt;br /&gt;
         &lt;br /&gt;
     ISample = (struct SampleIFace *)IExec-&amp;gt;GetInterface(SampleBase, &amp;quot;main&amp;quot;, 1, NULL);&lt;br /&gt;
     if(!ISample)&lt;br /&gt;
     {&lt;br /&gt;
         IExec-&amp;gt;CloseLibrary(SampleBase);&lt;br /&gt;
         return -2;&lt;br /&gt;
     }&lt;br /&gt;
     &lt;br /&gt;
     val1 = 123;&lt;br /&gt;
     val2 = 321;&lt;br /&gt;
     res = ISample-&amp;gt;Addition(val1, val2);&lt;br /&gt;
     printf(&amp;quot;%ld + %ld = %ld\n&amp;quot;, val1, val2, res);&lt;br /&gt;
     &lt;br /&gt;
     IExec-&amp;gt;DropInterface((struct Interface *)ISample);&lt;br /&gt;
     IExec-&amp;gt;CloseLibrary(SampleBase);&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Build it, copy your library in the same drawer (except if you already put it in Libs:) and test it&lt;br /&gt;
 9.test&amp;gt; gcc -g -o tst_sample tst_sample.c&lt;br /&gt;
 9.test&amp;gt; tst_sample &lt;br /&gt;
 123 + 321 = 444&lt;br /&gt;
&lt;br /&gt;
Et voila !&lt;br /&gt;
&lt;br /&gt;
Hope this article will help you create much usefull libraries.&lt;/div&gt;</summary>
		<author><name>Ölrick Lefebvre</name></author>
	</entry>
</feed>