106 lines
5.2 KiB
HTML
106 lines
5.2 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<!-- This manual documents Guile version 3.0.10.
|
||
|
|
||
|
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
|
||
|
Inc.
|
||
|
|
||
|
Copyright (C) 2021 Maxime Devos
|
||
|
|
||
|
Copyright (C) 2024 Tomas Volf
|
||
|
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||
|
any later version published by the Free Software Foundation; with no
|
||
|
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
|
||
|
copy of the license is included in the section entitled "GNU Free
|
||
|
Documentation License." -->
|
||
|
<title>Linking Guile with Libraries (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="Linking Guile with Libraries (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="Linking Guile with Libraries (Guile Reference Manual)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content=".texi2any-real">
|
||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
|
|
||
|
<link href="index.html" rel="start" title="Top">
|
||
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="Programming-in-C.html" rel="up" title="Programming in C">
|
||
|
<link href="General-Libguile-Concepts.html" rel="next" title="General Libguile Concepts">
|
||
|
<link href="Linking-Programs-With-Guile.html" rel="prev" title="Linking Programs With Guile">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
||
|
span:hover a.copiable-link {visibility: visible}
|
||
|
-->
|
||
|
</style>
|
||
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<div class="section-level-extent" id="Linking-Guile-with-Libraries">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="General-Libguile-Concepts.html" accesskey="n" rel="next">General concepts for using libguile</a>, Previous: <a href="Linking-Programs-With-Guile.html" accesskey="p" rel="prev">Linking Programs With Guile</a>, Up: <a href="Programming-in-C.html" accesskey="u" rel="up">Programming in C</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<h3 class="section" id="Linking-Guile-with-Libraries-1"><span>5.3 Linking Guile with Libraries<a class="copiable-link" href="#Linking-Guile-with-Libraries-1"> ¶</a></span></h3>
|
||
|
|
||
|
<p>The previous section has briefly explained how to write programs that
|
||
|
make use of an embedded Guile interpreter. But sometimes, all you
|
||
|
want to do is make new primitive procedures and data types available
|
||
|
to the Scheme programmer. Writing a new version of <code class="code">guile</code> is
|
||
|
inconvenient in this case and it would in fact make the life of the
|
||
|
users of your new features needlessly hard.
|
||
|
</p>
|
||
|
<p>For example, suppose that there is a program <code class="code">guile-db</code> that is a
|
||
|
version of Guile with additional features for accessing a database.
|
||
|
People who want to write Scheme programs that use these features would
|
||
|
have to use <code class="code">guile-db</code> instead of the usual <code class="code">guile</code> program.
|
||
|
Now suppose that there is also a program <code class="code">guile-gtk</code> that extends
|
||
|
Guile with access to the popular Gtk+ toolkit for graphical user
|
||
|
interfaces. People who want to write GUIs in Scheme would have to use
|
||
|
<code class="code">guile-gtk</code>. Now, what happens when you want to write a Scheme
|
||
|
application that uses a GUI to let the user access a database? You
|
||
|
would have to write a <em class="emph">third</em> program that incorporates both the
|
||
|
database stuff and the GUI stuff. This might not be easy (because
|
||
|
<code class="code">guile-gtk</code> might be a quite obscure program, say) and taking this
|
||
|
example further makes it easy to see that this approach can not work in
|
||
|
practice.
|
||
|
</p>
|
||
|
<p>It would have been much better if both the database features and the GUI
|
||
|
feature had been provided as libraries that can just be linked with
|
||
|
<code class="code">guile</code>. Guile makes it easy to do just this, and we encourage you
|
||
|
to make your extensions to Guile available as libraries whenever
|
||
|
possible.
|
||
|
</p>
|
||
|
<p>You write the new primitive procedures and data types in the normal
|
||
|
fashion, and link them into a shared library instead of into a
|
||
|
stand-alone program. The shared library can then be loaded dynamically
|
||
|
by Guile.
|
||
|
</p>
|
||
|
|
||
|
|
||
|
<ul class="mini-toc">
|
||
|
<li><a href="A-Sample-Guile-Extension.html" accesskey="1">A Sample Guile Extension</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="General-Libguile-Concepts.html">General concepts for using libguile</a>, Previous: <a href="Linking-Programs-With-Guile.html">Linking Programs With Guile</a>, Up: <a href="Programming-in-C.html">Programming in C</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|