swig/Examples/go/index.html
Corey Minyard 546763ffbc [Go] Add an example for goin and godirectorin
Shows how to use a go directory for passing an NULL terminated argv type
array.

This also exercises the bug in the previous commit.  That's why the
call1 function isn't assigned to zero, that the only case where that bug
happens.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2022-04-18 19:55:34 -05:00

99 lines
2.9 KiB
HTML

<html>
<head>
<title>SWIG:Examples:Go</title>
</head>
<body bgcolor="#ffffff">
<H1>SWIG Go Examples</H1>
<p>
The following examples illustrate the use of SWIG with Go.
<ul>
<li><a href="simple/index.html">simple</a>. A minimal example showing how SWIG can
be used to wrap a C function, a global variable, and a constant.
<li><a href="constants/index.html">constants</a>. This shows how preprocessor macros and
certain C declarations are turned into constants.
<li><a href="variables/index.html">variables</a>. An example showing how to access C global variables from Go.
<li><a href="enum/index.html">enum</a>. Wrapping enumerations.
<li><a href="class/index.html">class</a>. Wrapping a simple C++ class.
<li><a href="reference/index.html">reference</a>. C++ references.
<li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
<li><a href="funcptr/index.html">funcptr</a>. Pointers to functions.
<li><a href="template/index.html">template</a>. C++ templates.
<li><a href="callback/index.html">callback</a>. C++ callbacks using directors.
<li><a href="extend/index.html">extend</a>. Polymorphism using directors.
<li><a href="director/index.html">director</a>. Example how to utilize the director feature.
<li><a href="goin/index.html">director</a>. Example how to use goin and godirectorin.
</ul>
<h2>Compilation Issues</h2>
<ul>
<li>To create a Go extension, SWIG is run with the following options:
<blockquote>
<pre>
% swig -go interface.i
</pre>
</blockquote>
<li>On Unix the compilation of examples is done using the
file <tt>Example/Makefile</tt>. Normally builds are done simply
using <tt>go build</tt>. For testing purposes this makefile performs
a manual module compilation that is platform specific. When using
the <tt>gc</tt> compiler, the steps look approximately like this
(GNU/Linux):
<blockquote>
<pre>
% swig -go -cgo interface.i
% mkdir -p gopath/src/interface
% cp interface_wrap.c interface_wrap.h interface.go gopath/src/interface
% GOPATH=`pwd`/gopath
% export GOPATH
% cd gopath/src/interface
% go build
% go tool compile $(SRCDIR)/runme.go
% go tool link -o runme runme.o
</pre>
</blockquote>
<li>When using the <tt>gccgo</tt> compiler, the steps look like this:
<blockquote>
<pre>
% swig -go -cgo interface.i
% mkdir -p gopath/src/interface
% cp interface_wrap.c interface_wrap.h interface.go gopath/src/interface
% GOPATH=`pwd`/gopath
% export GOPATH
% cd gopath/src/interface
% go build
% gccgo -c $(SRCDIR)/runme.go
% gccgo -o runme runme.o interface.a
</pre>
</blockquote
</ul>
<h2>Compatibility</h2>
The examples have been extensively tested on the following platforms:
<ul>
<li>GNU/Linux
</ul>
All of the examples were last tested with the following configuration
(5 August 2015):
<ul>
<li>Ubuntu Trusty
<li>gcc-4.8.4
</ul>
Your mileage may vary. If you experience a problem, please let us know by
contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
</body>
</html>